Class: Faussaire::Address
- Inherits:
-
Object
- Object
- Faussaire::Address
- Defined in:
- lib/faussaire/address.rb
Constant Summary collapse
- DATA_PATH =
File.('../../locale/fr.yml', __dir__)
Class Method Summary collapse
-
.city ⇒ String
Produces a random city name.
-
.dpt_name ⇒ String
Produces a random department name.
-
.dpt_number ⇒ String
Produces a random department number for metropolitan France.
-
.dpt_number_other ⇒ String
Produces a random department number for overseas departments.
-
.full_address ⇒ String
Generates a complete address using various components such as street number, street type, street name, postal code, city, and region.
- .initialize_data ⇒ Object
-
.postal_code ⇒ String
Produces a random postal code, formatted to five digits.
-
.region ⇒ String
Produces a random region name.
-
.street_name ⇒ String
Produces a random street name.
-
.street_number_99 ⇒ String
Produces a random street number up to 99.
-
.street_number_999 ⇒ String
Produces a random street number up to 999.
-
.street_number_9999 ⇒ String
Produces a random street number up to 9999.
-
.street_type ⇒ String
Produces a random street type.
Class Method Details
.city ⇒ String
Produces a random city name.
20 21 22 |
# File 'lib/faussaire/address.rb', line 20 def city fetch('fr.faussaire.address.city') end |
.dpt_name ⇒ String
Produces a random department name.
92 93 94 |
# File 'lib/faussaire/address.rb', line 92 def dpt_name fetch('fr.faussaire.address.dpt_name') end |
.dpt_number ⇒ String
Produces a random department number for metropolitan France.
104 105 106 |
# File 'lib/faussaire/address.rb', line 104 def dpt_number fetch('fr.faussaire.address.dpt_number_metropolis') end |
.dpt_number_other ⇒ String
Produces a random department number for overseas departments.
116 117 118 |
# File 'lib/faussaire/address.rb', line 116 def dpt_number_other fetch('fr.faussaire.address.dpt_number_overseas') end |
.full_address ⇒ String
Generates a complete address using various components such as street number, street type, street name, postal code, city, and region.
154 155 156 157 158 159 160 161 162 163 164 165 166 |
# File 'lib/faussaire/address.rb', line 154 def full_address number = random_street_number type = street_type name = street_name postal = postal_code city_name = city department_name = dpt_name department_number = department_number_select reg = region "#{number} #{type} #{name}, #{postal} #{city_name}, #{department_name} (#{department_number}), Région #{reg}" end |
.initialize_data ⇒ Object
8 9 10 |
# File 'lib/faussaire/address.rb', line 8 def initialize_data @data = YAML.load_file(DATA_PATH) end |
.postal_code ⇒ String
Produces a random postal code, formatted to five digits.
128 129 130 131 |
# File 'lib/faussaire/address.rb', line 128 def postal_code code = fetch('fr.faussaire.address.postal_code') code.to_s.rjust(5, '0') end |
.region ⇒ String
Produces a random region name.
141 142 143 |
# File 'lib/faussaire/address.rb', line 141 def region fetch('fr.faussaire.address.region') end |
.street_name ⇒ String
Produces a random street name.
80 81 82 |
# File 'lib/faussaire/address.rb', line 80 def street_name fetch('fr.faussaire.address.street_name') end |
.street_number_99 ⇒ String
Produces a random street number up to 99.
32 33 34 |
# File 'lib/faussaire/address.rb', line 32 def street_number_99 fetch('fr.faussaire.address.street_number_99') end |
.street_number_999 ⇒ String
Produces a random street number up to 999.
44 45 46 |
# File 'lib/faussaire/address.rb', line 44 def street_number_999 fetch('fr.faussaire.address.street_number_999') end |
.street_number_9999 ⇒ String
Produces a random street number up to 9999.
56 57 58 |
# File 'lib/faussaire/address.rb', line 56 def street_number_9999 fetch('fr.faussaire.address.street_number_9999') end |
.street_type ⇒ String
Produces a random street type.
68 69 70 |
# File 'lib/faussaire/address.rb', line 68 def street_type fetch('fr.faussaire.address.street_type') end |