class Random
Magician's extensions to the Random
class.
Public Instance Methods
boolean()
click to toggle source
Returns a random boolean (true or false).
@return [Boolean] true or false
# File lib/magician/random.rb, line 13 def boolean [true, false].sample random: self end
coin()
click to toggle source
Returns a random coin toss (heads or tails).
@return [String] 'heads' or 'tails'
# File lib/magician/random.rb, line 20 def coin ['heads', 'tails'].sample random: self end
die()
click to toggle source
Returns a random die roll (from 1-6).
@return [Fixnum] a Fixnum from 1-6
# File lib/magician/random.rb, line 27 def die rand 1..6 end