class Ruby2JS::OpalEnumerator

Opal’s enumerator doesn’t currently support next and peek methods. Build a wrapper that adds those methods.

Public Class Methods

new(stream) click to toggle source
# File lib/ruby2js/jsx.rb, line 297
def initialize(stream)
  @stream = stream.to_a
end

Public Instance Methods

next() click to toggle source
# File lib/ruby2js/jsx.rb, line 301
def next
  raise StopIteration.new if @stream.empty?
  @stream.shift
end
peek() click to toggle source
# File lib/ruby2js/jsx.rb, line 306
def peek
  raise StopIteration.new if @stream.empty?
  @stream.first
end