Class: Faussaire::Name
- Inherits:
-
Object
- Object
- Faussaire::Name
- Defined in:
- lib/faussaire/name.rb
Constant Summary collapse
- DATA_PATH =
File.('../../locale/fr.yml', __dir__)
Class Method Summary collapse
-
.family_name ⇒ String
Produces a random family name.
-
.female_first_name ⇒ String
Produces a random female first name.
-
.initialize_data ⇒ Object
Initializes the data from the YAML file.
-
.male_first_name ⇒ String
Produces a random male first name.
-
.name ⇒ String
Generates a full name by combining a random first name (either male or female) with a family name.
Class Method Details
.family_name ⇒ String
Produces a random family name.
49 50 51 52 |
# File 'lib/faussaire/name.rb', line 49 def family_name key = 'fr.faussaire.name.family_name' fetch(key) end |
.female_first_name ⇒ String
Produces a random female first name.
23 24 25 26 |
# File 'lib/faussaire/name.rb', line 23 def female_first_name key = 'fr.faussaire.name.female_first_name' fetch(key) end |
.initialize_data ⇒ Object
Initializes the data from the YAML file.
11 12 13 |
# File 'lib/faussaire/name.rb', line 11 def initialize_data @data = YAML.load_file(DATA_PATH) end |
.male_first_name ⇒ String
Produces a random male first name.
36 37 38 39 |
# File 'lib/faussaire/name.rb', line 36 def male_first_name key = 'fr.faussaire.name.male_first_name' fetch(key) end |
.name ⇒ String
Generates a full name by combining a random first name (either male or female) with a family name.
62 63 64 65 |
# File 'lib/faussaire/name.rb', line 62 def name first_name = [female_first_name, male_first_name].sample [first_name, family_name].join(' ') end |