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.
6 7 8 9 10 11 |
# File 'opal/opal/corelib/enumerator/yielder.rb', line 6 def initialize(&block) @block = block # rubocop:disable Lint/Void self # rubocop:enable Lint/Void end |
Instance Method Details
#<<(value) ⇒ Object
25 26 27 28 29 |
# File 'opal/opal/corelib/enumerator/yielder.rb', line 25 def <<(value) self.yield(value) self end |
#to_proc ⇒ Object
31 32 33 34 35 |
# File 'opal/opal/corelib/enumerator/yielder.rb', line 31 def to_proc proc do |*values| self.yield(*values) end end |
#yield(*values) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'opal/opal/corelib/enumerator/yielder.rb', line 13 def yield(*values) %x{ var value = Opal.yieldX(#{@block}, values); if (value && value.$thrower_type == "break") { throw value; } return value; } end |