Class: Faker::Address
- Inherits:
-
Base
- Object
- Base
- Faker::Address
show all
- Defined in:
- lib/faker/address.rb
Class Method Summary
collapse
Methods inherited from Base
bothify, fetch, letterify, numerify
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
|
.city_prefix ⇒ Object
36
|
# File 'lib/faker/address.rb', line 36
def city_prefix; fetch('address.city_prefix'); end
|
.city_suffix ⇒ Object
35
|
# File 'lib/faker/address.rb', line 35
def city_suffix; fetch('address.city_suffix'); end
|
.country ⇒ Object
Also known as:
earth_country
39
|
# File 'lib/faker/address.rb', line 39
def country; fetch('address.country'); 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
44
45
46
47
48
49
50
51
|
# File 'lib/faker/address.rb', line 44
def method_missing(m, *args, &block)
if translation = I18n.translate(:faker)[: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
numerify(fetch('address.secondary_address'))
end
|
.state ⇒ Object
Also known as:
us_state
38
|
# File 'lib/faker/address.rb', line 38
def state; fetch('address.state'); end
|
.state_abbr ⇒ Object
Also known as:
us_state_abbr
37
|
# File 'lib/faker/address.rb', line 37
def state_abbr; fetch('address.state_abbr'); end
|
.street_address(include_secondary = false) ⇒ Object
20
21
22
|
# File 'lib/faker/address.rb', line 20
def street_address(include_secondary = false)
numerify("#{fetch('address.street_address')} #{street_name}#{' ' + secondary_address if include_secondary}")
end
|
.street_name ⇒ Object
13
14
15
16
17
18
|
# File 'lib/faker/address.rb', line 13
def street_name
[
Proc.new { [Name.last_name, street_suffix].join(' ') },
Proc.new { [Name.first_name, street_suffix].join(' ') }
].rand.call
end
|
.street_suffix ⇒ Object
34
|
# File 'lib/faker/address.rb', line 34
def street_suffix; fetch('address.street_suffix'); end
|
.uk_county ⇒ Object
58
|
# File 'lib/faker/address.rb', line 58
def uk_county; county; end
|
.zip_code ⇒ Object
Also known as:
zip, postcode, uk_postcode
28
29
30
|
# File 'lib/faker/address.rb', line 28
def zip_code
bothify(fetch('address.postcode')).upcase
end
|