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.
295 296 297 |
# File 'lib/ruby2js/jsx.rb', line 295 def initialize(stream) @stream = stream.to_a end |
Instance Method Details
#next ⇒ Object
299 300 301 302 |
# File 'lib/ruby2js/jsx.rb', line 299 def next raise StopIteration.new if @stream.empty? @stream.shift end |
#peek ⇒ Object
304 305 306 307 |
# File 'lib/ruby2js/jsx.rb', line 304 def peek raise StopIteration.new if @stream.empty? @stream.first end |