Class: Vial::Sequence

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

Instance Method Summary collapse

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_valueObject



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