Class: RPrec::ArrayStream
Overview
ArrayStream
is a simple implementation of RPrec::Stream
with an array.
Instance Method Summary collapse
- #current ⇒ RPrec::Token
- #eof? ⇒ Boolean
-
#initialize(tokens) ⇒ ArrayStream
constructor
A new instance of ArrayStream.
- #next ⇒ void
Methods inherited from Stream
Constructor Details
#initialize(tokens) ⇒ ArrayStream
Returns a new instance of ArrayStream.
9 10 11 12 13 |
# File 'lib/rprec/array_stream.rb', line 9 def initialize(tokens) super() @tokens = tokens @index = 0 end |
Instance Method Details
#current ⇒ RPrec::Token
16 17 18 19 20 |
# File 'lib/rprec/array_stream.rb', line 16 def current return Token.new('EOF') if eof? @tokens[@index] end |
#eof? ⇒ Boolean
29 30 31 |
# File 'lib/rprec/array_stream.rb', line 29 def eof? @index >= @tokens.size end |
#next ⇒ void
This method returns an undefined value.
23 24 25 26 |
# File 'lib/rprec/array_stream.rb', line 23 def next super @index += 1 end |