module MPatch::Extend::Random
Public Instance Methods
boolean()
click to toggle source
# File lib/mpatch/random.rb, line 21 def boolean self.rand(2) == 1 end
date(from = Time.at(1114924812), to = Time.now)
click to toggle source
# File lib/mpatch/random.rb, line 29 def date from = Time.at(1114924812), to = Time.now self.rand(from..to).to_date end
datetime(from = Time.at(1114924812), to = Time.now)
click to toggle source
# File lib/mpatch/random.rb, line 33 def datetime from = Time.at(1114924812), to = Time.now self.rand(from..to).to_datetime end
integer(length= 3)
click to toggle source
# File lib/mpatch/random.rb, line 17 def integer(length= 3) self.rand(length) end
string(length= 7,amount=1,hyphen= " ")
click to toggle source
# File lib/mpatch/random.rb, line 7 def string(length= 7,amount=1,hyphen= " ") amount_container= [] amount.times do mrg= "" mrg= (0...length).map{ ('a'..'z').to_a[rand(26)] }.join amount_container.push mrg end return amount_container.join(hyphen) end
time(from = Time.at(1114924812), to = Time.now)
click to toggle source
# File lib/mpatch/random.rb, line 25 def time from = Time.at(1114924812), to = Time.now self.rand(from..to) end