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

Instance Methods

Field Detail

scanLocation Integer

The current scan location. It is incremented by the scanner as the characters are processed. The default is 0: the beginning of the string.

string String

The string to scan. You usually pass it to the create method:

SC.Scanner.create({string: 'May, 8th'});

Instance Method Detail

scan(len)

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
scanArray(ary)
Attempts to scan any string in a given array.
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
scanInt(min_len, max_len)
Reads some characters from the string and interprets it as an integer.
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
skipString(str)
Attempts to skip a given string.
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
Documentation generated by JsDoc Toolkit 2.4.0 on Wed Apr 08 2015 10:02:21 GMT-0600 (CST)