Class: Laboratory::Algorithms::Random

Inherits:
Object
  • Object
show all
Defined in:
lib/laboratory/algorithms/random.rb

Class Method Summary collapse

Class Method Details

.idObject



8
9
10
# File 'lib/laboratory/algorithms/random.rb', line 8

def self.id
  'RANDOM'
end

.pick!(variants) ⇒ Object



4
5
6
# File 'lib/laboratory/algorithms/random.rb', line 4

def self.pick!(variants)
  variants.min_by { |variant| - variant.percentage * rand }
end