Class: SC.Scanner
Extends
SC.Object.
A Scanner reads a string and interprets the characters into numbers. You assign the scanner's string on initialization and the scanner progresses through the characters of that string from beginning to end as you request items.
Scanners are used by DateTime
to convert strings into DateTime
objects.
Defined in: datetime.js
- Since:
- SproutCore 1.0
Field Summary
- Fields borrowed from SC.Object:
- concatenatedProperties, isDestroyed, isObject, nextProperty, object, property, target, toInvalidate
- Fields borrowed from SC.Observable:
- isObservable
Instance Methods
Field Detail
scanLocation IntegerThe current scan location. It is incremented by the scanner as the characters are processed. The default is 0: the beginning of the string.
The string to scan. You usually pass it to the create method:
SC.Scanner.create(
{string: 'May, 8th'});
Instance Method Detail
Reads some characters from the string, and increments the scan location accordingly.
- Parameters:
- len Integer
- The amount of characters to read
- Returns:
- String
- The characters
- Throws:
- SC.SCANNER_OUT_OF_BOUNDS_ERROR
- If asked to read too many characters
- Parameters:
- ary Array
- the array of strings to scan
- Returns:
- Integer
- The index of the scanned string of the given array
- Throws:
- SC.SCANNER_SCAN_ARRAY_ERROR
- If no string of the given array is found
- Parameters:
- min_len Integer
- The minimum amount of characters to read
- max_len Integer Optional
- The maximum amount of characters to read (defaults to the minimum)
- Returns:
- Integer
- The scanned integer
- Throws:
- SC.SCANNER_INT_ERROR
- If asked to read non numeric characters
- Parameters:
- str String
- The string to skip
- Returns:
- Boolean
- YES if the given string was successfully scanned, NO otherwise
- Throws:
- SC.SCANNER_SKIP_ERROR
- If the given string could not be scanned