Module: Lottery

Defined in:
lib/copycats.rb

Overview

add wrapper for allowing configuration of random number generator

Class Method Summary collapse

Class Method Details

.rand(arg = nil) ⇒ Object



57
58
59
60
61
62
63
# File 'lib/copycats.rb', line 57

def self.rand( arg=nil )
  if arg.is_a? Integer
    random.rand( arg )  ## max (number) = arg
  else
    random.rand     ## between 0.0 and 1.0 (as floating point number)
  end
end

.randomObject



49
50
51
# File 'lib/copycats.rb', line 49

def self.random
  @random ||= Random.new
end

.random=(value) ⇒ Object



53
54
55
# File 'lib/copycats.rb', line 53

def self.random=(value)
  @random = value
end