Class: ScaleRb::Metadata::TypeExp::Tokenizer

Inherits:
Object
  • Object
show all
Defined in:
lib/scale_rb/metadata/type_exp.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#indexObject (readonly)

Returns the value of attribute index.



7
8
9
# File 'lib/scale_rb/metadata/type_exp.rb', line 7

def index
  @index
end

#tokensObject (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

Returns:

  • (Boolean)


28
29
30
# File 'lib/scale_rb/metadata/type_exp.rb', line 28

def eof?
  @index >= @tokens.length
end

#next_tokenObject

% 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_tokenObject

% peek_token

-> String



23
24
25
# File 'lib/scale_rb/metadata/type_exp.rb', line 23

def peek_token
  @tokens[@index]
end