module Faker::Internet

Constants

BYTE
DISPOSABLE_HOSTS
DOMAIN_SUFFIXES
HOSTS

Public Instance Methods

disposable_email(name = nil) click to toggle source

returns an email address of an online disposable email service (like tempinbox.com). you can really send an email to these addresses an access it by going to the service web pages.

# File lib/ffakerer/internet.rb, line 14
def disposable_email(name = nil)
  [ user_name(name), DISPOSABLE_HOSTS.rand ].join('@')
end
domain_name() click to toggle source
# File lib/ffakerer/internet.rb, line 40
def domain_name
  "#{domain_word}.#{domain_suffix}"
end
domain_suffix() click to toggle source
# File lib/ffakerer/internet.rb, line 51
def domain_suffix
  DOMAIN_SUFFIXES.rand
end
domain_word() click to toggle source
# File lib/ffakerer/internet.rb, line 44
def domain_word
  dw = Company.name.split(' ').first
  dw.gsub!(/\W/, '')
  dw.downcase!
  dw
end
email(name = nil) click to toggle source
# File lib/ffakerer/internet.rb, line 8
def email(name = nil)
  [ user_name(name), domain_name ].join('@')
end
free_email(name = nil) click to toggle source
# File lib/ffakerer/internet.rb, line 18
def free_email(name = nil)
  "#{user_name(name)}@#{HOSTS.rand}"
end
http_url() click to toggle source
# File lib/ffakerer/internet.rb, line 59
def http_url
  uri("http")
end
ip_v4_address() click to toggle source
# File lib/ffakerer/internet.rb, line 63
def ip_v4_address
  (1..4).map { BYTE.random_pick(1) }.join(".")
end
uri(protocol) click to toggle source
# File lib/ffakerer/internet.rb, line 55
def uri(protocol)
  "#{protocol}://#{domain_name}"
end
user_name(name = nil) click to toggle source
# File lib/ffakerer/internet.rb, line 22
def user_name(name = nil)
  if name
    parts = ArrayUtils.shuffle(name.scan(/\w+/)).join(ArrayUtils.rand(%w(. _)))
    parts.downcase!
    parts
  else
    case rand(2)
    when 0
      Name.first_name.gsub(/\W/, '').downcase
    when 1
      parts = [ Name.first_name, Name.last_name ].each {|n| n.gsub!(/\W/, '') }
      parts = parts.join ArrayUtils.rand(%w(. _))
      parts.downcase!
      parts
    end
  end
end