Skip to content
Snippets Groups Projects
Commit 2ab17e6d authored by Alex Reisner's avatar Alex Reisner
Browse files

Clean up state/province code.

parent 1a2ea730
No related branches found
No related tags found
No related merge requests found
...@@ -34,19 +34,14 @@ module Geocoder::Result ...@@ -34,19 +34,14 @@ module Geocoder::Result
end end
def country_code def country_code
prov = @data['prov'] return nil if state.nil? || state == ""
return nil if prov.nil? || prov == "" canadian_province_abbreviations.include?(state) ? "CA" : "US"
canadian_province_abbreviations.include?(@data['prov']) ? "CA" : "US"
end
def canadian_province_abbreviations
%w[ON QC NS NB MB BC PE SK AB NL]
end end
def self.response_attributes def self.response_attributes
%w[latt longt inlatt inlongt betweenRoad1 betweenRoad2 distance %w[latt longt inlatt inlongt distance stnumber staddress prov
stnumber staddress prov postal NearRoad NearRoadDistance betweenRoad1 betweenRoad2
NearRoad NearRoadDistance intersection major_intersection] intersection major_intersection]
end end
response_attributes.each do |a| response_attributes.each do |a|
...@@ -54,5 +49,12 @@ module Geocoder::Result ...@@ -54,5 +49,12 @@ module Geocoder::Result
@data[a] @data[a]
end end
end end
private # ----------------------------------------------------------------
def canadian_province_abbreviations
%w[ON QC NS NB MB BC PE SK AB NL]
end
end end
end end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment