Class: Array
- Inherits:
-
Object
- Object
- Array
- Defined in:
- lib/chance/core_extensions.rb
Instance Method Summary collapse
Instance Method Details
#pick(percent) ⇒ Object
47 48 49 50 51 52 53 54 |
# File 'lib/chance/core_extensions.rb', line 47 def pick(percent) picks, percentage = [], percent.of(length).round while picks.length < percentage picks << random picks.uniq! end picks end |
#pick_about(percentage) ⇒ Object
56 57 58 |
# File 'lib/chance/core_extensions.rb', line 56 def pick_about(percentage) select {|element| percentage.chance.happens? } end |
#random ⇒ Object
39 40 41 |
# File 'lib/chance/core_extensions.rb', line 39 def random self[rand(length)] end |
#random_pop ⇒ Object
43 44 45 |
# File 'lib/chance/core_extensions.rb', line 43 def random_pop delete_at rand(length) end |