Class: LaunchDarkly::Impl::Sampler Private
- Inherits:
-
Object
- Object
- LaunchDarkly::Impl::Sampler
- Defined in:
- lib/ldclient-rb/impl/sampler.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Method Summary collapse
-
#initialize(random) ⇒ Sampler
constructor
private
A new instance of Sampler.
- #sample(ratio) ⇒ Boolean private
Constructor Details
#initialize(random) ⇒ Sampler
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Sampler.
7 8 9 |
# File 'lib/ldclient-rb/impl/sampler.rb', line 7 def initialize(random) @random = random end |
Instance Method Details
#sample(ratio) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
16 17 18 19 20 21 22 |
# File 'lib/ldclient-rb/impl/sampler.rb', line 16 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 |