Skip to content

Instantly share code, notes, and snippets.

@huobazi
Forked from adambird/random.rb
Last active August 29, 2015 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save huobazi/cd668b250c8d6224833e to your computer and use it in GitHub Desktop.
Save huobazi/cd668b250c8d6224833e to your computer and use it in GitHub Desktop.
def random_string
(0...24).map{ ('a'..'z').to_a[rand(26)] }.join
end
def random_symbol
random_string.to_sym
end
def random_integer
rand(9999)
end
def random_float
random_integer + rand
end
def random_time
(Time.now + random_integer.minutes).utc
end
def random_date
Time.new(random_time.year, random_time.month, random_time.day)
end
def random_email
"#{random_string}@#{random_domain}"
end
def random_domain
"#{random_string}.com"
end
def random_url
"http://#{random_string}.#{random_domain}/#{random_string}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment