Skip to content

Commit

Permalink
Added boolValue method to CPString
Browse files Browse the repository at this point in the history
  • Loading branch information
vijaykiran committed Sep 14, 2008
1 parent 2eae537 commit 1b2aadc
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Foundation/CPString.j
Expand Up @@ -460,6 +460,19 @@ CPNumericSearch
return eval(self);
}

/*
Returns <code>YES</code> on encountering one of "Y", "y", "T", "t", or
a digit 1-9. Returns <code>NO</code> otherwise. This method skips the initial
whitespace characters, +,- followed by Zeroes.
*/
- (BOOL)boolValue
{
aString = self.replace(/^\s+[\+,-]*0*/,"");
if(aString.match(/[Y,y,t,T,[1-9]/) != null)
return YES;
return NO;
}

/*
Returns the text as a float point value.
*/
Expand Down

0 comments on commit 1b2aadc

Please sign in to comment.