Sha256: 4924cda44477317068ca52f8a17a34eb4aaae8cd1c8a0a211dcd542f99762dab

Contents?: true

Size: 451 Bytes

Versions: 15

Compression:

Stored size: 451 Bytes

Contents

module LaunchDarkly
  module Impl
    class Sampler
      #
      # @param random [Random]
      #
      def initialize(random)
        @random = random
      end

      #
      # @param ratio [Int]
      #
      # @return [Boolean]
      #
      def sample(ratio)
        return false unless ratio.is_a? Integer
        return false if ratio <= 0
        return true if ratio == 1

        @random.rand(1.0) < 1.0 / ratio
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
launchdarkly-server-sdk-8.8.2 lib/ldclient-rb/impl/sampler.rb
launchdarkly-server-sdk-8.8.1 lib/ldclient-rb/impl/sampler.rb
launchdarkly-server-sdk-8.8.0 lib/ldclient-rb/impl/sampler.rb
launchdarkly-server-sdk-8.7.1 lib/ldclient-rb/impl/sampler.rb
launchdarkly-server-sdk-8.7.0 lib/ldclient-rb/impl/sampler.rb
launchdarkly-server-sdk-8.6.0 lib/ldclient-rb/impl/sampler.rb
launchdarkly-server-sdk-8.5.0 lib/ldclient-rb/impl/sampler.rb
launchdarkly-server-sdk-8.4.2 lib/ldclient-rb/impl/sampler.rb
launchdarkly-server-sdk-8.4.1 lib/ldclient-rb/impl/sampler.rb
launchdarkly-server-sdk-8.4.0 lib/ldclient-rb/impl/sampler.rb
launchdarkly-server-sdk-8.3.1 lib/ldclient-rb/impl/sampler.rb
launchdarkly-server-sdk-8.3.0 lib/ldclient-rb/impl/sampler.rb
launchdarkly-server-sdk-8.2.0 lib/ldclient-rb/impl/sampler.rb
launchdarkly-server-sdk-8.1.0 lib/ldclient-rb/impl/sampler.rb
launchdarkly-server-sdk-8.0.0 lib/ldclient-rb/impl/sampler.rb