Module: RandomData::ContactInfo

Included in:
Random
Defined in:
lib/random_data/contact_info.rb

Overview

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

Instance Method Summary collapse

Instance Method Details

#emailObject

Returns an e-mail address of the form “first_initiallast_name@domain”



19
20
21
22
# 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_phoneObject

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.



14
15
16
# File 'lib/random_data/contact_info.rb', line 14

def international_phone
 "011-#{rand(100) + 1}-#{rand(100)+10}-#{rand(10000)+1000}"
end

#phoneObject

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



7
8
9
# File 'lib/random_data/contact_info.rb', line 7

def phone
  "#{rand(900) + 100}-#{rand(900)+100}-#{rand(10000)+1000}"
end