Method: Keybox::Randomizer#pick_count_from

Defined in:
lib/keybox/randomizer.rb

#pick_count_from(array, count = 1) ⇒ Object

Raises:

  • (ArgumentError)


176
177
178
179
180
181
182
183
184
185
# File 'lib/keybox/randomizer.rb', line 176

def pick_count_from(array, count = 1)
    raise ArgumentError, "Unable to pick from object of class #{array.class.name}" unless has_correct_duck_type?(array)
    results = []
    range = array.size
    count.times do
        rand_index = random_source.rand(range)
        results << array.at(rand_index)
    end
    results
end