Class: Enumerator::Yielder

Inherits:
Object show all
Defined in:
lib/backports/enumerator.rb

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ Yielder

Returns a new instance of Yielder.



21
22
23
# File 'lib/backports/enumerator.rb', line 21

def initialize(&block)
  @main_block = block
end

Instance Method Details

#each(&block) ⇒ Object



25
26
27
28
# File 'lib/backports/enumerator.rb', line 25

def each(&block)
  @final_block = block
  @main_block.call(self)
end

#yield(*arg) ⇒ Object



30
31
32
# File 'lib/backports/enumerator.rb', line 30

def yield(*arg)
  @final_block.yield(*arg)
end