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.1"

Class Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**options) ⇒ RRandom

Returns a new instance of RRandom.



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

def initialize(**options)
  options.each do |key, value|
    instance_variable_set(:"@#{key}", value)
  end
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



65
66
67
# File 'lib/rrandom.rb', line 65

def domain
  "example.com"
end

#emailObject



61
62
63
# File 'lib/rrandom.rb', line 61

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

#first_nameObject



46
47
48
49
50
51
# File 'lib/rrandom.rb', line 46

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



42
43
44
# File 'lib/rrandom.rb', line 42

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

#last_nameObject



53
54
55
# File 'lib/rrandom.rb', line 53

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

#nameObject



57
58
59
# File 'lib/rrandom.rb', line 57

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