Class: RouletteWheelSelection

Inherits:
Object
  • Object
show all
Defined in:
lib/roulette-wheel-selection.rb,
lib/roulette-wheel-selection/version.rb

Constant Summary collapse

VERSION =
"1.0.1"

Class Method Summary collapse

Class Method Details

.sample(*args) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/roulette-wheel-selection.rb', line 5

def sample(*args)
  object = args.first
  case object
  when Array ; sample_from_array(*args)
  when Hash  ; sample_from_hash(*args)
  else       ; fail "Unsupported type: #{object.class}"
  end
end