class Object
Public Instance Methods
rand_let(options={})
click to toggle source
Returns a random upper or lowercase letter
# File lib/random-utils.rb, line 7 def rand_let options={} uppercase = random(0, 2) == 1 uppercaseLet = random(65, 91).chr letter = (uppercase) ? (uppercaseLet) : (uppercaseLet.downcase) letter end
rand_phone(options={})
click to toggle source
Returns a random phone number w/ an area code of 210 (no international prefixes)
# File lib/random-utils.rb, line 15 def rand_phone options={} "210#{random(1111111, 9999999).to_s}" end
rand_token(length=36)
click to toggle source
Gets a random length (default 36) character string consisting of uppercase and lowercase letters and numbers 0-9
# File lib/random-utils.rb, line 21 def rand_token length=36 token = '' length.times do token += (random(0, 2)==1) ? (random(0,10).to_s) : (rand_let()) end token end
random(min, max, options={})
click to toggle source
Returns a number >= min, but <= max
# File lib/random-utils.rb, line 2 def random min, max, options={} rand(max - min) + min end