Odds based random number generator
class Odds def self.true?(chance=0) (rand(chance)<1) end end
For example for 1 in 4 odds you would call
Odds.true?(4)
For a dead cert true? or true?(0) would always return true. Check out the other links for a slightly modified version which is optimised for known low failure rates.