lib/geokit/geocoders/ca_geocoder.rb in geokit-1.8.5 vs lib/geokit/geocoders/ca_geocoder.rb in geokit-1.9.0

- old
+ new

@@ -8,39 +8,39 @@ # <geodata> # <latt>49.243086</latt> # <longt>-123.153684</longt> # </geodata> module Geokit - module Geocoders - class CaGeocoder < Geocoder - config :key + module Geocoders + class CaGeocoder < Geocoder + config :key - private + private - # Template method which does the geocode lookup. - def self.do_geocode(loc) - raise ArgumentError('Geocoder.ca requires a GeoLoc argument') unless loc.is_a?(GeoLoc) - process :xml, submit_url(loc), loc - end + # Template method which does the geocode lookup. + def self.do_geocode(loc) + raise ArgumentError('Geocoder.ca requires a GeoLoc argument') unless loc.is_a?(GeoLoc) + process :xml, submit_url(loc), loc + end - def self.parse_xml(xml, loc) - loc.lat = xml.elements['//latt'].text - loc.lng = xml.elements['//longt'].text - loc.success = true - loc - end + def self.parse_xml(xml, loc) + loc.lat = xml.elements['//latt'].text + loc.lng = xml.elements['//longt'].text + loc.success = true + loc + end - # Formats the request in the format acceptable by the CA geocoder. - def self.submit_url(loc) - args = [] - args << "stno=#{loc.street_number}" if loc.street_address - args << "addresst=#{Geokit::Inflector::url_escape(loc.street_name)}" if loc.street_address - args << "city=#{Geokit::Inflector::url_escape(loc.city)}" if loc.city - args << "prov=#{loc.state}" if loc.state - args << "postal=#{loc.zip}" if loc.zip - args << "auth=#{key}" if key - args << "geoit=xml" - 'http://geocoder.ca/?' + args.join('&') - end - end - end + # Formats the request in the format acceptable by the CA geocoder. + def self.submit_url(loc) + args = [] + args << "stno=#{loc.street_number}" if loc.street_address + args << "addresst=#{Geokit::Inflector.url_escape(loc.street_name)}" if loc.street_address + args << "city=#{Geokit::Inflector.url_escape(loc.city)}" if loc.city + args << "prov=#{loc.state}" if loc.state + args << "postal=#{loc.zip}" if loc.zip + args << "auth=#{key}" if key + args << 'geoit=xml' + 'http://geocoder.ca/?' + args.join('&') + end + end + end end