Class: WeightedList::Sampler

Inherits:
Object
  • Object
show all
Defined in:
lib/weighted_list/sampler.rb

Defined Under Namespace

Classes: Result

Instance Method Summary collapse

Constructor Details

#initialize(hash:, random:) ⇒ Sampler

Returns a new instance of Sampler.



5
6
7
8
# File 'lib/weighted_list/sampler.rb', line 5

def initialize(hash:, random:)
  @hash = hash
  @random = random
end

Instance Method Details

#callObject



10
11
12
# File 'lib/weighted_list/sampler.rb', line 10

def call
  Result.new(selected, remaining)
end