Class: Geocoder::Result::GeocoderCa
- Inherits:
-
Base
- Object
- Base
- Geocoder::Result::GeocoderCa
show all
- Defined in:
- lib/geocoder/results/geocoder_ca.rb
Instance Attribute Summary
Attributes inherited from Base
#cache_hit, #data
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#initialize, #latitude, #longitude, #province, #province_code
Class Method Details
.response_attributes ⇒ Object
41
42
43
44
45
|
# File 'lib/geocoder/results/geocoder_ca.rb', line 41
def self.response_attributes
%w[latt longt inlatt inlongt distance stnumber staddress prov
NearRoad NearRoadDistance betweenRoad1 betweenRoad2
intersection major_intersection]
end
|
Instance Method Details
#address(format = :full) ⇒ Object
10
11
12
|
# File 'lib/geocoder/results/geocoder_ca.rb', line 10
def address(format = :full)
"#{street_address}, #{city}, #{state} #{postal_code}, #{country}".sub(/^[ ,]*/, "")
end
|
#city ⇒ Object
18
19
20
|
# File 'lib/geocoder/results/geocoder_ca.rb', line 18
def city
@data['city']
end
|
#coordinates ⇒ Object
6
7
8
|
# File 'lib/geocoder/results/geocoder_ca.rb', line 6
def coordinates
[@data['latt'].to_f, @data['longt'].to_f]
end
|
#country ⇒ Object
32
33
34
|
# File 'lib/geocoder/results/geocoder_ca.rb', line 32
def country
country_code == 'CA' ? 'Canada' : 'United States'
end
|
#country_code ⇒ Object
36
37
38
39
|
# File 'lib/geocoder/results/geocoder_ca.rb', line 36
def country_code
return nil if state.nil? || state == ""
canadian_province_abbreviations.include?(state) ? "CA" : "US"
end
|
#postal_code ⇒ Object
28
29
30
|
# File 'lib/geocoder/results/geocoder_ca.rb', line 28
def postal_code
@data['postal']
end
|
#state ⇒ Object
Also known as:
state_code
22
23
24
|
# File 'lib/geocoder/results/geocoder_ca.rb', line 22
def state
@data['prov']
end
|
#street_address ⇒ Object
14
15
16
|
# File 'lib/geocoder/results/geocoder_ca.rb', line 14
def street_address
"#{@data['stnumber']} #{@data['staddress']}"
end
|