Class: Faker::Address
- Inherits:
-
Object
- Object
- Faker::Address
- Defined in:
- lib/faker/address.rb
Class Method Summary collapse
- .city ⇒ Object
-
.method_missing(m, *args, &block) ⇒ Object
You can add whatever you want to the locale file, and it will get caught here…
- .secondary_address ⇒ Object
- .street_address(include_secondary = false) ⇒ Object
- .street_name ⇒ Object
- .zip_code ⇒ Object (also: zip, postcode, uk_postcode)
Class Method Details
.city ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/faker/address.rb', line 4 def city [ '%s %s%s' % [city_prefix, Name.first_name, city_suffix], '%s %s' % [city_prefix, Name.first_name], '%s%s' % [Name.first_name, city_suffix], '%s%s' % [Name.last_name, city_suffix], ].rand end |
.method_missing(m, *args, &block) ⇒ Object
You can add whatever you want to the locale file, and it will get caught here… e.g., create a country_code array in your locale, then you can call #country_code and it will act like #country
43 44 45 46 47 48 49 50 |
# File 'lib/faker/address.rb', line 43 def method_missing(m, *args, &block) # Use the alternate form of translate to get a nil rather than a "missing translation" string if translation = I18n.translate(:address)[m] translation.respond_to?(:rand) ? translation.rand : translation else super end end |
.secondary_address ⇒ Object
24 25 26 |
# File 'lib/faker/address.rb', line 24 def secondary_address Faker.numerify(I18n.translate('address.secondary_address').rand) end |
.street_address(include_secondary = false) ⇒ Object
20 21 22 |
# File 'lib/faker/address.rb', line 20 def street_address(include_secondary = false) Faker.numerify("#{I18n.translate('address.street_address').rand} #{street_name}#{' ' + secondary_address if include_secondary}") end |