Class: DutchFaker::Internet

Inherits:
Object
  • Object
show all
Defined in:
lib/dutchfaker/internet.rb

Constant Summary collapse

DOMAIN_SUFFIXES =
%w(nl com org eu)
FREE_EMAIL_SUFFIXES =
%w(gmail.com yahoo.com hotmail.com)

Class Method Summary collapse

Class Method Details

.domain_nameObject



31
32
33
# File 'lib/dutchfaker/internet.rb', line 31

def domain_name
  "#{domain_word}.#{domain_suffix}"
end

.domain_suffixObject



39
40
41
# File 'lib/dutchfaker/internet.rb', line 39

def domain_suffix
  DOMAIN_SUFFIXES.rand
end

.domain_wordObject



35
36
37
# File 'lib/dutchfaker/internet.rb', line 35

def domain_word
  Company.name.split(' ').first.gsub(/\W/, '').downcase
end

.email(name = nil) ⇒ Object



8
9
10
# File 'lib/dutchfaker/internet.rb', line 8

def email(name = nil)
  "#{user_name(name)}@#{domain_name}"
end

.free_email(name = nil) ⇒ Object



12
13
14
# File 'lib/dutchfaker/internet.rb', line 12

def free_email(name = nil)
  "#{user_name(name)}@#{free_email_suffix}"
end

.free_email_suffixObject



16
17
18
# File 'lib/dutchfaker/internet.rb', line 16

def free_email_suffix
  FREE_EMAIL_SUFFIXES.rand
end

.user_name(name = nil) ⇒ Object



20
21
22
23
24
25
26
27
28
29
# File 'lib/dutchfaker/internet.rb', line 20

def user_name(name = nil)
  return name.scan(/\w+/).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

.web_site(name = nil) ⇒ Object



43
44
45
# File 'lib/dutchfaker/internet.rb', line 43

def web_site(name = nil)
  "www.#{domain_name}"
end