Class: Enumerator::Yielder
- Defined in:
- lib/backports/1.9.1/enumerator/new.rb,
lib/backports/2.0.0/enumerable/lazy.rb
Overview
A simple class which allows the construction of Enumerator from a block
Instance Attribute Summary collapse
-
#backports_memo ⇒ Object
Current API for Lazy Enumerator does not provide an easy way to handle internal state.
Instance Method Summary collapse
- #<<(*arg) ⇒ Object
-
#initialize(&block) ⇒ Yielder
constructor
A new instance of Yielder.
- #yield(*arg) ⇒ Object
Constructor Details
#initialize(&block) ⇒ Yielder
Returns a new instance of Yielder.
10 11 12 |
# File 'lib/backports/1.9.1/enumerator/new.rb', line 10 def initialize(&block) @final_block = block end |
Instance Attribute Details
#backports_memo ⇒ Object
Current API for Lazy Enumerator does not provide an easy way to handle internal state. We “cheat” and use yielder to hold it for us. A new yielder is created when generating or after a ‘rewind`. This way we avoid issues like bugs.ruby-lang.org/issues/7691 or bugs.ruby-lang.org/issues/7696
19 20 21 |
# File 'lib/backports/2.0.0/enumerable/lazy.rb', line 19 def backports_memo @backports_memo end |