Class: Datadog::Utils::Sequence

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

Overview

Generates values from a consistent sequence

Instance Method Summary collapse

Constructor Details

#initialize(seed = 0, &block) ⇒ Sequence

Returns a new instance of Sequence.



6
7
8
9
# File 'lib/ddtrace/utils/sequence.rb', line 6

def initialize(seed = 0, &block)
  @current = seed
  @next_item = block
end

Instance Method Details

#nextObject



11
12
13
14
15
# File 'lib/ddtrace/utils/sequence.rb', line 11

def next
  next_item = @next_item ? @next_item.call(@current) : @current
  @current += 1
  next_item
end