Sha256: 4df453343e0d31d9f921865baffe0e1f914ad059fd77ce6b88cf7ca3eced766f

Contents?: true

Size: 514 Bytes

Versions: 32

Compression:

Stored size: 514 Bytes

Contents

# frozen_string_literal: true

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

32 entries across 32 versions & 2 rubygems

Version Path
datadog-2.7.0 lib/datadog/core/utils/sequence.rb
datadog-2.6.0 lib/datadog/core/utils/sequence.rb
datadog-2.5.0 lib/datadog/core/utils/sequence.rb
datadog-2.4.0 lib/datadog/core/utils/sequence.rb
datadog-2.3.0 lib/datadog/core/utils/sequence.rb
datadog-2.2.0 lib/datadog/core/utils/sequence.rb
ddtrace-1.23.3 lib/datadog/core/utils/sequence.rb
ddtrace-1.23.2 lib/datadog/core/utils/sequence.rb
datadog-2.1.0 lib/datadog/core/utils/sequence.rb
datadog-2.0.0 lib/datadog/core/utils/sequence.rb
ddtrace-1.23.1 lib/datadog/core/utils/sequence.rb
datadog-2.0.0.beta2 lib/datadog/core/utils/sequence.rb
ddtrace-1.22.0 lib/datadog/core/utils/sequence.rb
datadog-2.0.0.beta1 lib/datadog/core/utils/sequence.rb
ddtrace-1.21.1 lib/datadog/core/utils/sequence.rb
ddtrace-1.21.0 lib/datadog/core/utils/sequence.rb
ddtrace-1.20.0 lib/datadog/core/utils/sequence.rb
ddtrace-1.19.0 lib/datadog/core/utils/sequence.rb
ddtrace-1.18.0 lib/datadog/core/utils/sequence.rb
ddtrace-1.17.0 lib/datadog/core/utils/sequence.rb