Class: Shuriken::Tokens

Inherits:
Object
  • Object
show all
Defined in:
lib/shuriken/tokens.rb

Instance Method Summary collapse

Constructor Details

#initialize(tokens) ⇒ Tokens

Returns a new instance of Tokens.



10
11
12
13
# File 'lib/shuriken/tokens.rb', line 10

def initialize(tokens)
	@tokens = tokens
	@token_i = 0
end

Instance Method Details

#curObject



37
38
39
# File 'lib/shuriken/tokens.rb', line 37

def cur
	@tokens[@token_i]
end

#forwardObject



33
34
35
# File 'lib/shuriken/tokens.rb', line 33

def forward
	@token_i += 1 
end

#go_nextObject



24
25
26
27
28
29
30
31
# File 'lib/shuriken/tokens.rb', line 24

def go_next
	v = nil
	if @token_i < @tokens.length
		v = @tokens[@token_i]
		@token_i += 1 
	end
	return v
end

#ok?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/shuriken/tokens.rb', line 20

def ok?
	return @token_i < @tokens.length ? true : false
end

#peek(n) ⇒ Object



15
16
17
18
# File 'lib/shuriken/tokens.rb', line 15

def peek(n)
	return nil if @token_i + n < 0 || @token_i + n >= @tokens.length
	@tokens[@token_i + n]
end