Class: Faker::Internet
- Defined in:
- lib/gems/faker-0.3.1/lib/faker/internet.rb
Class Method Summary collapse
- .domain_name ⇒ Object
- .domain_suffix ⇒ Object
- .domain_word ⇒ Object
- .email(name = nil) ⇒ Object
- .free_email(name = nil) ⇒ Object
- .user_name(name = nil) ⇒ Object
Class Method Details
.domain_name ⇒ Object
24 25 26 |
# File 'lib/gems/faker-0.3.1/lib/faker/internet.rb', line 24 def domain_name [ domain_word, domain_suffix ].join('.') end |
.domain_suffix ⇒ Object
32 33 34 |
# File 'lib/gems/faker-0.3.1/lib/faker/internet.rb', line 32 def domain_suffix %w(co.uk com us uk ca biz info name).rand end |
.domain_word ⇒ Object
28 29 30 |
# File 'lib/gems/faker-0.3.1/lib/faker/internet.rb', line 28 def domain_word Company.name.split(' ').first.gsub(/\W/, '').downcase end |
.email(name = nil) ⇒ Object
4 5 6 |
# File 'lib/gems/faker-0.3.1/lib/faker/internet.rb', line 4 def email(name = nil) [ user_name(name), domain_name ].join('@') end |
.free_email(name = nil) ⇒ Object
8 9 10 |
# File 'lib/gems/faker-0.3.1/lib/faker/internet.rb', line 8 def free_email(name = nil) [ user_name(name), %w(gmail.com yahoo.com hotmail.com).rand ].join('@') end |
.user_name(name = nil) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/gems/faker-0.3.1/lib/faker/internet.rb', line 12 def user_name(name = nil) return name.scan(/\w+/).shuffle.join(%w(. _).rand).downcase if name [ Proc.new { Name.first_name.gsub(/\W/, '').downcase }, Proc.new { [ Name.first_name, Name.last_name ].map {|n| n.gsub(/\W/, '') }.join(%w(. _).rand).downcase } ].rand.call end |