module RandomData::ContactInfo

Methods for randomly generating contact data like phone numbers and e-mail addresses

Public Instance Methods

email() click to toggle source

Returns an e-mail address of the form “{first_initial}{last_name}@{domain}”

# File lib/random_data/contact_info.rb, line 19
def email 
 domains = %w(yahoo.com gmail.com privacy.net webmail.com msn.com hotmail.com example.com privacy.net)
 "#{(initial + lastname).downcase}\@#{domains.rand}"  
end
international_phone() click to toggle source

Returns a randomly-generated string of digits that roughly resembles an international telephone number as dialed from the US.

Not guaranteed to be a valid number but just good enough to get some sample data going.

# File lib/random_data/contact_info.rb, line 14
def international_phone
 "011-#{rand(100) + 1}-#{rand(100)+10}-#{rand(10000)+1000}"
end
phone() click to toggle source

Returns a randomly-generated string of digits that roughly resembles a US telephone number. Not guaranteed to be a valid area code.

# File lib/random_data/contact_info.rb, line 7
def phone
  "#{rand(900) + 100}-#{rand(900)+100}-#{rand(10000)+1000}"
end