Class: Datadog::Core::Utils::Sequence

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

Overview

Generates values from a consistent sequence

Instance Method Summary collapse

Constructor Details

#initialize(seed = 0) ⇒ Sequence

Returns a new instance of Sequence.



8
9
10
11
# File 'lib/datadog/core/utils/sequence.rb', line 8

def initialize(seed = 0)
  @seed = seed
  @current = seed
end

Instance Method Details

#next ⇒ Object



13
14
15
16
17
# File 'lib/datadog/core/utils/sequence.rb', line 13

def next
  current = @current
  @current += 1
  current
end

#reset! ⇒ Object



19
20
21
# File 'lib/datadog/core/utils/sequence.rb', line 19

def reset!
  @current = @seed
end