Repository navigation
Expand file tree
/
Copy pathaddress.rb
More file actions
55 lines (43 loc) · 1.31 KB
/
Copy pathaddress.rb
File metadata and controls
55 lines (43 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
module Faker
class Address < Base
flexible :address
class << self
def city
parse('address.city')
end
def street_name
parse('address.street_name')
end
def street_address(include_secondary = false)
numerify(parse('address.street_address') + (include_secondary ? ' ' + secondary_address : ''))
end
def secondary_address
numerify(fetch('address.secondary_address'))
end
def building_number
bothify(fetch('address.building_number'))
end
def zip_code
bothify(fetch('address.postcode'))
end
def time_zone
bothify(fetch('address.time_zone'))
end
alias_method :zip, :zip_code
alias_method :postcode, :zip_code
def street_suffix; fetch('address.street_suffix'); end
def city_suffix; fetch('address.city_suffix'); end
def city_prefix; fetch('address.city_prefix'); end
def state_abbr; fetch('address.state_abbr'); end
def state; fetch('address.state'); end
def country; fetch('address.country'); end
def country_code; fetch('address.country_code'); end
def latitude
((rand * 180) - 90).to_s
end
def longitude
((rand * 360) - 180).to_s
end
end
end
end