Class: Faker::Address
- Inherits:
-
Base
- Object
- Base
- Faker::Address
show all
- Defined in:
- lib/faker/address.rb
Constant Summary
Constants inherited
from Base
Base::Letters, Base::Numbers, Base::ULetters
Class Method Summary
collapse
Methods inherited from Base
bothify, fetch, fetch_all, flexible, letterify, method_missing, numerify, parse, rand, rand_in_range, regexify, respond_to_missing?, sample, shuffle, translate, unique, with_locale
Class Method Details
.building_number ⇒ Object
22
23
24
|
# File 'lib/faker/address.rb', line 22
def building_number
bothify(fetch('address.building_number'))
end
|
.city(options = {}) ⇒ Object
6
7
8
|
# File 'lib/faker/address.rb', line 6
def city(options = {})
parse(options[:with_state] ? 'address.city_with_state' : 'address.city')
end
|
.city_prefix ⇒ Object
56
57
58
|
# File 'lib/faker/address.rb', line 56
def city_prefix
fetch('address.city_prefix')
end
|
.city_suffix ⇒ Object
52
53
54
|
# File 'lib/faker/address.rb', line 52
def city_suffix
fetch('address.city_suffix')
end
|
26
27
28
|
# File 'lib/faker/address.rb', line 26
def
parse('address.community')
end
|
.country ⇒ Object
68
69
70
|
# File 'lib/faker/address.rb', line 68
def country
fetch('address.country')
end
|
.country_code ⇒ Object
72
73
74
|
# File 'lib/faker/address.rb', line 72
def country_code
fetch('address.country_code')
end
|
.country_code_long ⇒ Object
76
77
78
|
# File 'lib/faker/address.rb', line 76
def country_code_long
fetch('address.country_code_long')
end
|
.full_address ⇒ Object
88
89
90
|
# File 'lib/faker/address.rb', line 88
def full_address
parse('address.full_address')
end
|
.latitude ⇒ Object
80
81
82
|
# File 'lib/faker/address.rb', line 80
def latitude
((rand * 180) - 90).to_f
end
|
.longitude ⇒ Object
84
85
86
|
# File 'lib/faker/address.rb', line 84
def longitude
((rand * 360) - 180).to_f
end
|
.secondary_address ⇒ Object
18
19
20
|
# File 'lib/faker/address.rb', line 18
def secondary_address
bothify(fetch('address.secondary_address'))
end
|
.state ⇒ Object
64
65
66
|
# File 'lib/faker/address.rb', line 64
def state
fetch('address.state')
end
|
.state_abbr ⇒ Object
60
61
62
|
# File 'lib/faker/address.rb', line 60
def state_abbr
fetch('address.state_abbr')
end
|
.street_address(include_secondary = false) ⇒ Object
14
15
16
|
# File 'lib/faker/address.rb', line 14
def street_address(include_secondary = false)
numerify(parse('address.street_address') + (include_secondary ? ' ' + secondary_address : ''))
end
|
.street_name ⇒ Object
10
11
12
|
# File 'lib/faker/address.rb', line 10
def street_name
parse('address.street_name')
end
|
.street_suffix ⇒ Object
48
49
50
|
# File 'lib/faker/address.rb', line 48
def street_suffix
fetch('address.street_suffix')
end
|
.time_zone ⇒ Object
41
42
43
|
# File 'lib/faker/address.rb', line 41
def time_zone
fetch('address.time_zone')
end
|
.zip_code(state_abbreviation = '') ⇒ Object
Also known as:
zip, postcode
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/faker/address.rb', line 30
def zip_code(state_abbreviation = '')
if state_abbreviation.empty?
letterified_string = letterify(fetch('address.postcode'))
return numerify(letterified_string, leading_zero: true)
end
bothify(fetch('address.postcode_by_state.' + state_abbreviation))
end
|