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