Module: IcodiCore::Randomization

Included in:
Icodi
Defined in:
lib/icodi/randomization.rb

Instance Method Summary collapse

Instance Method Details

#random(set = nil) ⇒ Object



7
8
9
10
# File 'lib/icodi/randomization.rb', line 7

def random(set = nil)
  set ||= :default
  random_sets[set] ||= (text ? Random.new(seed(text)) : Random.new)
end

#random_setsObject



12
13
14
# File 'lib/icodi/randomization.rb', line 12

def random_sets
  @random_sets ||= {}
end

#seed(string) ⇒ Object



3
4
5
# File 'lib/icodi/randomization.rb', line 3

def seed(string)
  Digest::MD5.hexdigest(string).to_i(16)
end