Class: Ruby2JS::OpalEnumerator
- Inherits:
-
Object
- Object
- Ruby2JS::OpalEnumerator
- Defined in:
- lib/ruby2js/jsx.rb
Overview
Opal’s enumerator doesn’t currently support next and peek methods. Build a wrapper that adds those methods.
Instance Method Summary collapse
-
#initialize(stream) ⇒ OpalEnumerator
constructor
A new instance of OpalEnumerator.
- #next ⇒ Object
- #peek ⇒ Object
Constructor Details
#initialize(stream) ⇒ OpalEnumerator
Returns a new instance of OpalEnumerator.
297 298 299 |
# File 'lib/ruby2js/jsx.rb', line 297 def initialize(stream) @stream = stream.to_a end |
Instance Method Details
#next ⇒ Object
301 302 303 304 |
# File 'lib/ruby2js/jsx.rb', line 301 def next raise StopIteration.new if @stream.empty? @stream.shift end |
#peek ⇒ Object
306 307 308 309 |
# File 'lib/ruby2js/jsx.rb', line 306 def peek raise StopIteration.new if @stream.empty? @stream.first end |