Class: Datadog::Core::Utils::Sequence
- Inherits:
-
Object
- Object
- Datadog::Core::Utils::Sequence
- Defined in:
- lib/datadog/core/utils/sequence.rb
Overview
Generates values from a consistent sequence
Instance Method Summary collapse
-
#initialize(seed = 0) ⇒ Sequence
constructor
A new instance of Sequence.
- #next ⇒ Object
- #reset! ⇒ Object
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 |