Class: Forgery::Internet

Inherits:
Forgery show all
Defined in:
lib/forgery/forgery/internet.rb

Constant Summary

Constant Summary

Constants inherited from Forgery

VERSION

Class Method Summary (collapse)

Methods inherited from Forgery

Extend, dictionaries, formats, load_from!, load_paths, rails?, rails_root

Class Method Details

+ (Object) cctld



25
26
27
# File 'lib/forgery/forgery/internet.rb', line 25

def self.cctld
  dictionaries[:country_code_top_level_domains].random.unextend
end

+ (Object) domain_name



13
14
15
# File 'lib/forgery/forgery/internet.rb', line 13

def self.domain_name
  dictionaries[:company_names].random.downcase + '.' + self.top_level_domain
end

+ (Object) email_address



17
18
19
# File 'lib/forgery/forgery/internet.rb', line 17

def self.email_address
  user_name + '@' + domain_name
end

+ (Object) email_subject(options = {})



21
22
23
# File 'lib/forgery/forgery/internet.rb', line 21

def self.email_subject(options={})
  Forgery::LoremIpsum.title(options)
end

+ (Object) ip_v4



29
30
31
# File 'lib/forgery/forgery/internet.rb', line 29

def self.ip_v4
  (1..4).map{rand(256)}.join('.')
end

+ (Object) ip_v6

credit for this method from stackoverflow.com/a/2811349/793330



34
35
36
# File 'lib/forgery/forgery/internet.rb', line 34

def self.ip_v6
  IPAddr.new(rand(2**128),Socket::AF_INET6).to_s
end

+ (Object) top_level_domain



9
10
11
# File 'lib/forgery/forgery/internet.rb', line 9

def self.top_level_domain
  dictionaries[:top_level_domains].random.unextend
end

+ (Object) user_name



5
6
7
# File 'lib/forgery/forgery/internet.rb', line 5

def self.user_name
  (dictionaries[:male_first_names].random[0,1] + dictionaries[:last_names].random).downcase
end