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
#data
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#initialize, #latitude, #longitude
Class Method Details
.response_attributes ⇒ Object
46
47
48
49
50
|
# File 'lib/geocoder/results/geocoder_ca.rb', line 46
def self.response_attributes
%w[latt longt inlatt inlongt betweenRoad1 betweenRoad2 distance
stnumber staddress city prov postal
NearRoad NearRoadDistance 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}"
end
|
#canadian_province_abbreviations ⇒ Object
42
43
44
|
# File 'lib/geocoder/results/geocoder_ca.rb', line 42
def canadian_province_abbreviations
%w[ON QC NS NB MB BC PE SK AB NL]
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
40
|
# File 'lib/geocoder/results/geocoder_ca.rb', line 36
def country_code
prov = @data['prov']
return nil if prov.nil? || prov == ""
canadian_province_abbreviations.include?(@data['prov']) ? "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:
province
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
|