Class: TfgSupport::Sequence
- Inherits:
-
Object
- Object
- TfgSupport::Sequence
- Defined in:
- lib/tfg_support/sequence.rb
Instance Method Summary collapse
-
#initialize(args, &block) ⇒ Sequence
constructor
A new instance of Sequence.
-
#next ⇒ Object
return the next element in the sequence.
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
#next ⇒ Object
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 |