Sha256: 3ae36ee635ed9bcaf52fb3c50585ee52f9b2cc804d81c7e05f632ab83824e4bf
Contents?: true
Size: 851 Bytes
Versions: 5
Compression:
Stored size: 851 Bytes
Contents
module Barometer # # Web Service: Geocode # # uses Google Maps Geocoding service # class WebService::Geocode < WebService def self.fetch(query) raise ArgumentError unless _is_a_query?(query) puts "geocoding: #{query.q}" if Barometer::debug? return nil unless _has_geocode_key? location = self.get( "http://maps.google.com/maps/geo", :query => { :gl => query.country_code, :key => Barometer.google_geocode_key, :output => "xml", :q => query.q }, :format => :xml, :timeout => Barometer.timeout ) location = location['kml']['Response'] if location && location['kml'] location ? (geo = Data::Geo.new(location)) : nil end private def self._has_geocode_key? !Barometer.google_geocode_key.nil? end end end
Version data entries
5 entries across 5 versions & 2 rubygems