Class: Hash
- Inherits:
-
Object
- Object
- Hash
- Defined in:
- lib/roulette_wheel_selection/hash/sample.rb
Instance Method Summary collapse
- #roulette_wheel_selection(n = nil) ⇒ Object (also: #sample)
Instance Method Details
#roulette_wheel_selection(n = nil) ⇒ Object Also known as: sample
2 3 4 5 6 7 8 |
# File 'lib/roulette_wheel_selection/hash/sample.rb', line 2 def roulette_wheel_selection n=nil indexes = self.values.roulette_wheel_selection n return nil if indexes.nil? return self.keys[ indexes ] unless Array === indexes self.keys.values_at *indexes end |