Class: Vial::Sequence
- Inherits:
-
Object
- Object
- Vial::Sequence
- Defined in:
- lib/vial/sequence.rb
Instance Method Summary collapse
-
#initialize(start: 1, &block) ⇒ Sequence
constructor
A new instance of Sequence.
- #next_value ⇒ Object
Constructor Details
#initialize(start: 1, &block) ⇒ Sequence
Returns a new instance of Sequence.
5 6 7 8 |
# File 'lib/vial/sequence.rb', line 5 def initialize(start: 1, &block) @value = start @block = block end |
Instance Method Details
#next_value ⇒ Object
10 11 12 13 14 |
# File 'lib/vial/sequence.rb', line 10 def next_value current = @value @value += 1 @block ? @block.call(current) : current end |