Class: Enumerator::Yielder
- Defined in:
- opal/opal/corelib/enumerator/yielder.rb
Instance Method Summary collapse
- #<<(value) ⇒ Object
- 
  
    
      #initialize(&block)  ⇒ Yielder 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of Yielder. 
- #to_proc ⇒ Object
- #yield(*values) ⇒ Object
Constructor Details
#initialize(&block) ⇒ Yielder
Returns a new instance of Yielder.
| 5 6 7 8 9 10 | # File 'opal/opal/corelib/enumerator/yielder.rb', line 5 def initialize(&block) @block = block # rubocop:disable Lint/Void self # rubocop:enable Lint/Void end | 
Instance Method Details
#<<(value) ⇒ Object
| 24 25 26 27 28 | # File 'opal/opal/corelib/enumerator/yielder.rb', line 24 def <<(value) self.yield(value) self end | 
#to_proc ⇒ Object
| 30 31 32 33 34 | # File 'opal/opal/corelib/enumerator/yielder.rb', line 30 def to_proc proc do |*values| self.yield(*values) end end | 
#yield(*values) ⇒ Object
| 12 13 14 15 16 17 18 19 20 21 22 | # File 'opal/opal/corelib/enumerator/yielder.rb', line 12 def yield(*values) %x{ var value = Opal.yieldX(#{@block}, values); if (value && value.$thrower_type == "break") { throw value; } return value; } end |