Module: FFaker::Address
- Extended by:
- Address, ModuleUtils
- Included in:
- Address, AddressAU, AddressBR, AddressCA, AddressCH, AddressDA, AddressDE, AddressFI, AddressFR, AddressGR, AddressID, AddressIN, AddressJA, AddressNL, AddressRU, AddressSE, AddressSN, AddressUK, AddressUS
- Defined in:
- lib/ffaker/address.rb
Constant Summary
collapse
- COMPASS_DIRECTIONS =
%w[North East West South].freeze
- CITY_PREFIXES =
COMPASS_DIRECTIONS + %w[New Lake Port]
- SEC_ADDR =
['Apt. ###', 'Suite ###'].freeze
Instance Method Summary
collapse
const_missing, k, luhn_check, underscore, unique
#fetch_sample, #rand, #shuffle
Instance Method Details
#building_number ⇒ Object
50
51
52
|
# File 'lib/ffaker/address.rb', line 50
def building_number
FFaker.numerify(('#' * rand(3..5)))
end
|
#city ⇒ Object
37
38
39
40
41
42
43
44
|
# File 'lib/ffaker/address.rb', line 37
def city
case rand(0..3)
when 0 then "#{city_prefix} #{Name.first_name}#{city_suffix}"
when 1 then "#{city_prefix} #{Name.first_name}"
when 2 then "#{Name.first_name}#{city_suffix}"
when 3 then "#{Name.last_name}#{city_suffix}"
end
end
|
#city_prefix ⇒ Object
29
30
31
|
# File 'lib/ffaker/address.rb', line 29
def city_prefix
fetch_sample(CITY_PREFIXES)
end
|
#city_suffix ⇒ Object
33
34
35
|
# File 'lib/ffaker/address.rb', line 33
def city_suffix
fetch_sample(CITY_SUFFIXES)
end
|
#country(given_code = nil) ⇒ Object
93
94
95
96
97
98
99
100
|
# File 'lib/ffaker/address.rb', line 93
def country(given_code = nil)
country_index = COUNTRY_CODE.index(given_code)
if given_code && country_index
COUNTRY[country_index]
else
fetch_sample(COUNTRY)
end
end
|
#country_code(given_country = nil) ⇒ Object
102
103
104
105
106
107
108
109
|
# File 'lib/ffaker/address.rb', line 102
def country_code(given_country = nil)
code_index = COUNTRY.index(given_country)
if given_country && code_index
COUNTRY_CODE[code_index]
else
fetch_sample(COUNTRY_CODE)
end
end
|
#neighborhood ⇒ Object
89
90
91
|
# File 'lib/ffaker/address.rb', line 89
def neighborhood
fetch_sample(NEIGHBORHOOD)
end
|
#secondary_address ⇒ Object
67
68
69
|
# File 'lib/ffaker/address.rb', line 67
def secondary_address
FFaker.numerify(fetch_sample(SEC_ADDR))
end
|
#street_address(include_secondary = false) ⇒ Object
61
62
63
64
65
|
# File 'lib/ffaker/address.rb', line 61
def street_address(include_secondary = false)
str = +"#{building_number} #{street_name}"
str << " #{secondary_address}" if include_secondary
str
end
|
#street_name ⇒ Object
54
55
56
57
58
59
|
# File 'lib/ffaker/address.rb', line 54
def street_name
case rand(0..1)
when 0 then "#{Name.last_name} #{street_suffix}"
when 1 then "#{Name.first_name} #{street_suffix}"
end
end
|
#street_suffix ⇒ Object
46
47
48
|
# File 'lib/ffaker/address.rb', line 46
def street_suffix
fetch_sample(STREET_SUFFIX)
end
|
#time_zone ⇒ Object
111
112
113
|
# File 'lib/ffaker/address.rb', line 111
def time_zone
fetch_sample(TIME_ZONE)
end
|
#uk_country ⇒ Object
78
79
80
81
|
# File 'lib/ffaker/address.rb', line 78
def uk_country
warn '[uk_country] is deprecated. For UK addresses please use the AddressUK module'
FFaker::AddressUK.country
end
|
#uk_county ⇒ Object
73
74
75
76
|
# File 'lib/ffaker/address.rb', line 73
def uk_county
warn '[uk_county] is deprecated. For UK addresses please use the AddressUK module'
FFaker::AddressUK.county
end
|
#uk_postcode ⇒ Object
83
84
85
86
|
# File 'lib/ffaker/address.rb', line 83
def uk_postcode
warn '[uk_postcode] is deprecated. For UK addresses please use the AddressUK module'
FFaker::AddressUK.postcode
end
|
#us_state ⇒ Object
18
19
20
21
|
# File 'lib/ffaker/address.rb', line 18
def us_state
warn '[us_state] is deprecated. For US addresses please use the AddressUS module'
FFaker::AddressUS.state
end
|
#us_state_abbr ⇒ Object
23
24
25
26
|
# File 'lib/ffaker/address.rb', line 23
def us_state_abbr
warn '[state_abbr] is deprecated. For US addresses please use the AddressUS module'
FFaker::AddressUS.state_abbr
end
|
#zip_code ⇒ Object
13
14
15
16
|
# File 'lib/ffaker/address.rb', line 13
def zip_code
warn '[zip_code] is deprecated. For US addresses please use the AddressUS module'
FFaker::AddressUS.zip_code
end
|