Class: RomanNameGenerator::Generator
- Inherits:
-
Object
- Object
- RomanNameGenerator::Generator
- Defined in:
- lib/roman_name_generator.rb
Overview
The Generator class handles the loading and randomizing the json data store containing the roman name stub json. By default you only need to call the initializer, and as soon as it is instantiated, it builds a random roman name based on the gender given.
To get a new name, either initialize a new generator, or call #regenerate
Example:
full_name = RomanNameGenerator::Generator.new("male").result
Instance Attribute Summary collapse
-
#gender ⇒ Object
Returns the value of attribute gender.
-
#name_data ⇒ Object
Returns the value of attribute name_data.
-
#result ⇒ Object
Returns the value of attribute result.
Instance Method Summary collapse
-
#initialize(gender = "male") ⇒ Generator
constructor
Generates a random name and assigns it to #result.
-
#regenerate ⇒ Object
Gives another random roman name based on the gender given in the constructor, assigns it to #result, and then returns #result.
Constructor Details
#initialize(gender = "male") ⇒ Generator
Generates a random name and assigns it to #result
24 25 26 27 |
# File 'lib/roman_name_generator.rb', line 24 def initialize(gender="male") self.gender = gender generate end |
Instance Attribute Details
#gender ⇒ Object
Returns the value of attribute gender.
20 21 22 |
# File 'lib/roman_name_generator.rb', line 20 def gender @gender end |
#name_data ⇒ Object
Returns the value of attribute name_data.
20 21 22 |
# File 'lib/roman_name_generator.rb', line 20 def name_data @name_data end |
#result ⇒ Object
Returns the value of attribute result.
20 21 22 |
# File 'lib/roman_name_generator.rb', line 20 def result @result end |
Instance Method Details
#regenerate ⇒ Object
Gives another random roman name based on the gender given in the constructor, assigns it to #result, and then returns #result
31 32 33 |
# File 'lib/roman_name_generator.rb', line 31 def regenerate generate end |