Class: RRandom

Inherits:
Object
  • Object
show all
Defined in:
lib/rrandom.rb,
lib/rrandom/version.rb

Defined Under Namespace

Classes: Error, Loader

Constant Summary collapse

VERSION =
"0.1.0"

Class Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(random_domain: false) ⇒ RRandom

Returns a new instance of RRandom.



36
37
38
# File 'lib/rrandom.rb', line 36

def initialize(random_domain: false)
  @use_random_domain = random_domain
end

Class Attribute Details

.loaderObject

Returns the value of attribute loader.



33
34
35
# File 'lib/rrandom.rb', line 33

def loader
  @loader
end

Instance Method Details

#domainObject



67
68
69
# File 'lib/rrandom.rb', line 67

def domain
  "example.com"
end

#emailObject



63
64
65
# File 'lib/rrandom.rb', line 63

def email
  "#{first_name.downcase}.#{last_name.downcase}@#{domain}"
end

#first_nameObject



48
49
50
51
52
53
# File 'lib/rrandom.rb', line 48

def first_name
  @first_name ||= case gender
    when "male" then RRandom.loader.get(:male_first_names).sample.chomp
    when "female" then RRandom.loader.get(:female_first_names).sample.chomp
  end
end

#genderObject



44
45
46
# File 'lib/rrandom.rb', line 44

def gender
  @gender ||= ["male", "female"].sample
end

#last_nameObject



55
56
57
# File 'lib/rrandom.rb', line 55

def last_name
  @last_name ||= RRandom.loader.get(:last_names).sample.chomp
end

#nameObject



59
60
61
# File 'lib/rrandom.rb', line 59

def name
  "#{first_name} #{last_name}"
end

#use_random_domain?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/rrandom.rb', line 40

def use_random_domain?
  @use_random_domain
end