Class: Proc::Enumerator

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/proc/enumerator.rb

Instance Method Summary collapse

Constructor Details

#initialize(values, &next_block) ⇒ Enumerator

Returns a new instance of Enumerator.



7
8
9
10
# File 'lib/proc/enumerator.rb', line 7

def initialize(values, &next_block)
  @values = values
  @next_block = next_block
end

Instance Method Details

#each(&block) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/proc/enumerator.rb', line 12

def each(&block)
  return to_enum(:each) unless block

  @values.each(&block)

  if @next_block
    @next_block.call.each(&block)
  end
end