Class: RRandom
- Inherits:
-
Object
- Object
- RRandom
- Defined in:
- lib/rrandom.rb,
lib/rrandom/version.rb
Defined Under Namespace
Constant Summary collapse
- VERSION =
"0.1.1"
Class Attribute Summary collapse
-
.loader ⇒ Object
Returns the value of attribute loader.
Instance Method Summary collapse
- #domain ⇒ Object
- #email ⇒ Object
- #first_name ⇒ Object
- #gender ⇒ Object
-
#initialize(**options) ⇒ RRandom
constructor
A new instance of RRandom.
- #last_name ⇒ Object
- #name ⇒ Object
Constructor Details
#initialize(**options) ⇒ RRandom
Returns a new instance of RRandom.
36 37 38 39 40 |
# File 'lib/rrandom.rb', line 36 def initialize(**) .each do |key, value| instance_variable_set(:"@#{key}", value) end end |
Class Attribute Details
.loader ⇒ Object
Returns the value of attribute loader.
33 34 35 |
# File 'lib/rrandom.rb', line 33 def loader @loader end |
Instance Method Details
#domain ⇒ Object
65 66 67 |
# File 'lib/rrandom.rb', line 65 def domain "example.com" end |
#email ⇒ Object
61 62 63 |
# File 'lib/rrandom.rb', line 61 def email "#{first_name.downcase}.#{last_name.downcase}@#{domain}" end |
#first_name ⇒ Object
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 |
#gender ⇒ Object
42 43 44 |
# File 'lib/rrandom.rb', line 42 def gender @gender ||= ["male", "female"].sample end |
#last_name ⇒ Object
53 54 55 |
# File 'lib/rrandom.rb', line 53 def last_name @last_name ||= RRandom.loader.get(:last_names).sample.chomp end |
#name ⇒ Object
57 58 59 |
# File 'lib/rrandom.rb', line 57 def name "#{first_name} #{last_name}" end |