Sha256: 3a3ae12a300fdb713b4ce15d03b51cf72109cbea9538ef49723ea0586d7d8fd9

Contents?: true

Size: 483 Bytes

Versions: 2

Compression:

Stored size: 483 Bytes

Contents

module Datadog
  module Core
    module Utils
      # Generates values from a consistent sequence
      class Sequence
        def initialize(seed = 0, &block)
          @seed = seed
          @current = seed
          @next_item = block
        end

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

        def reset!
          @current = @seed
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ddtrace-1.10.1 lib/datadog/core/utils/sequence.rb
ddtrace-1.10.0 lib/datadog/core/utils/sequence.rb