Class: Enumerator::Yielder

Inherits:
Object
  • Object
show all
Defined in:
opal/opal/corelib/enumerator.rb

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ Yielder

Returns a new instance of Yielder



131
132
133
# File 'opal/opal/corelib/enumerator.rb', line 131

def initialize(&block)
  @block = block
end

Instance Method Details

#<<(*values) ⇒ Object



147
148
149
150
151
# File 'opal/opal/corelib/enumerator.rb', line 147

def <<(*values)
  self.yield(*values)

  self
end

#yield(*values) ⇒ Object



135
136
137
138
139
140
141
142
143
144
145
# File 'opal/opal/corelib/enumerator.rb', line 135

def yield(*values)
  %x{
    var value = $opal.$yieldX(#@block, values);

    if (value === $breaker) {
      throw $breaker;
    }

    return value;
  }
end