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



133
134
135
# File 'opal/opal/corelib/enumerator.rb', line 133

def initialize(&block)
  @block = block
end

Instance Method Details

#<<(*values) ⇒ Object



149
150
151
152
153
# File 'opal/opal/corelib/enumerator.rb', line 149

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

  self
end

#yield(*values) ⇒ Object



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

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

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

    return value;
  }
end