Class: TfgSupport::Sequence

Inherits:
Object
  • Object
show all
Defined in:
lib/tfg_support/sequence.rb

Instance Method Summary collapse

Constructor Details

#initialize(args, &block) ⇒ Sequence

Returns a new instance of Sequence.



4
5
6
# File 'lib/tfg_support/sequence.rb', line 4

def initialize(args, &block)
  @current_value, @generator = args, block
end

Instance Method Details

#nextObject

return the next element in the sequence



10
11
12
13
14
# File 'lib/tfg_support/sequence.rb', line 10

def next
  @current_value = @generator.call(@current_value) if @called
  @called = true
  @current_value
end