class Enumerator::Yielder
A simple class which allows the construction of Enumerator
from a block
Attributes
backports_memo[RW]
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
Public Class Methods
new(&block)
click to toggle source
# File lib/backports/1.9.1/enumerator/new.rb, line 10 def initialize(&block) @final_block = block end
Public Instance Methods
<<(*arg)
click to toggle source
# File lib/backports/1.9.1/enumerator/new.rb, line 18 def <<(*arg) @final_block.call(*arg) self end
yield(*arg)
click to toggle source
# File lib/backports/1.9.1/enumerator/new.rb, line 14 def yield(*arg) @final_block.call(*arg) end