Class: ScaleRb::Metadata::TypeExp::Tokenizer
- Inherits:
-
Object
- Object
- ScaleRb::Metadata::TypeExp::Tokenizer
- Defined in:
- lib/scale_rb/metadata/type_exp.rb
Instance Attribute Summary collapse
-
#index ⇒ Object
readonly
Returns the value of attribute index.
-
#tokens ⇒ Object
readonly
Returns the value of attribute tokens.
Instance Method Summary collapse
-
#eof? ⇒ Boolean
- % eof?
-
-> Bool.
-
#initialize(type_exp) ⇒ Tokenizer
constructor
- % tokenize
-
String -> [String].
-
#next_token ⇒ Object
- % next_token
-
-> String.
-
#peek_token ⇒ Object
- % peek_token
-
-> String.
Constructor Details
#initialize(type_exp) ⇒ Tokenizer
- % tokenize
-
String -> [String]
10 11 12 13 |
# File 'lib/scale_rb/metadata/type_exp.rb', line 10 def initialize(type_exp) @tokens = tokenize(type_exp) @index = 0 end |
Instance Attribute Details
#index ⇒ Object (readonly)
Returns the value of attribute index.
7 8 9 |
# File 'lib/scale_rb/metadata/type_exp.rb', line 7 def index @index end |
#tokens ⇒ Object (readonly)
Returns the value of attribute tokens.
7 8 9 |
# File 'lib/scale_rb/metadata/type_exp.rb', line 7 def tokens @tokens end |
Instance Method Details
#eof? ⇒ Boolean
- % eof?
-
-> Bool
28 29 30 |
# File 'lib/scale_rb/metadata/type_exp.rb', line 28 def eof? @index >= @tokens.length end |
#next_token ⇒ Object
- % next_token
-
-> String
16 17 18 19 20 |
# File 'lib/scale_rb/metadata/type_exp.rb', line 16 def next_token token = @tokens[@index] @index += 1 token end |
#peek_token ⇒ Object
- % peek_token
-
-> String
23 24 25 |
# File 'lib/scale_rb/metadata/type_exp.rb', line 23 def peek_token @tokens[@index] end |