Module: Faker::Address
- Extended by:
- Address, ModuleUtils
- Included in:
- Address, AddressAU, AddressCA, AddressDA, AddressDE, AddressMX, AddressSE, AddressSN, AddressUK, AddressUS
- Defined in:
- lib/ffakerer/address.rb
Constant Summary
collapse
- COMPASS_DIRECTIONS =
k %w(North East West South)
- CITY_PREFIXES =
k(COMPASS_DIRECTIONS + %w(New Lake Port))
- SEC_ADDR =
k ['Apt. ###', 'Suite ###']
Instance Method Summary
collapse
const_missing, k, underscore
Instance Method Details
#building_number ⇒ Object
46
47
48
|
# File 'lib/ffakerer/address.rb', line 46
def building_number
Faker.numerify(( '#' * rand(3) ) << '###')
end
|
#city ⇒ Object
33
34
35
36
37
38
39
40
|
# File 'lib/ffakerer/address.rb', line 33
def city
case rand(4)
when 0 then '%s %s%s' % [city_prefix, Name.first_name, city_suffix]
when 1 then '%s %s' % [city_prefix, Name.first_name]
when 2 then '%s%s' % [Name.first_name, city_suffix]
when 3 then '%s%s' % [Name.last_name, city_suffix]
end
end
|
#city_prefix ⇒ Object
25
26
27
|
# File 'lib/ffakerer/address.rb', line 25
def city_prefix
CITY_PREFIXES.rand
end
|
#city_suffix ⇒ Object
29
30
31
|
# File 'lib/ffakerer/address.rb', line 29
def city_suffix
CITY_SUFFIXES.rand
end
|
#country ⇒ Object
89
90
91
|
# File 'lib/ffakerer/address.rb', line 89
def country
COUNTRY.rand
end
|
#neighborhood ⇒ Object
85
86
87
|
# File 'lib/ffakerer/address.rb', line 85
def neighborhood
NEIGHBORHOOD.rand
end
|
#secondary_address ⇒ Object
63
64
65
|
# File 'lib/ffakerer/address.rb', line 63
def secondary_address
Faker.numerify(SEC_ADDR.rand)
end
|
#street_address(include_secondary = false) ⇒ Object
57
58
59
60
61
|
# File 'lib/ffakerer/address.rb', line 57
def street_address(include_secondary = false)
str = "#{building_number} #{street_name}"
str << " #{secondary_address}" if include_secondary
str
end
|
#street_name ⇒ Object
50
51
52
53
54
55
|
# File 'lib/ffakerer/address.rb', line 50
def street_name
case rand(2)
when 0 then "#{Name.last_name} #{street_suffix}"
when 1 then "#{Name.first_name} #{street_suffix}"
end
end
|
#street_suffix ⇒ Object
42
43
44
|
# File 'lib/ffakerer/address.rb', line 42
def street_suffix
STREET_SUFFIX.rand
end
|
#uk_country ⇒ Object
74
75
76
77
|
# File 'lib/ffakerer/address.rb', line 74
def uk_country
warn '[uk_country] is deprecated. For UK addresses please use the AddressUK module'
Faker::AddressUK.country
end
|
#uk_county ⇒ Object
69
70
71
72
|
# File 'lib/ffakerer/address.rb', line 69
def uk_county
warn '[uk_county] is deprecated. For UK addresses please use the AddressUK module'
Faker::AddressUK.county
end
|
#uk_postcode ⇒ Object
79
80
81
82
|
# File 'lib/ffakerer/address.rb', line 79
def uk_postcode
warn '[uk_postcode] is deprecated. For UK addresses please use the AddressUK module'
Faker::AddressUK.postcode
end
|
#us_state ⇒ Object
14
15
16
17
|
# File 'lib/ffakerer/address.rb', line 14
def us_state
warn '[us_state] is deprecated. For US addresses please use the AddressUS module'
Faker::AddressUS.state
end
|
#us_state_abbr ⇒ Object
19
20
21
22
|
# File 'lib/ffakerer/address.rb', line 19
def us_state_abbr
warn '[state_abbr] is deprecated. For US addresses please use the AddressUS module'
Faker::AddressUS.state_abbr
end
|
#zip_code ⇒ Object
9
10
11
12
|
# File 'lib/ffakerer/address.rb', line 9
def zip_code
warn '[zip_code] is deprecated. For US addresses please use the AddressUS module'
Faker::AddressUS.zip_code
end
|