Sha256: cf550b53b95a149dd5c0abbf5e0448965f7e5777b9d6665d2286395108345df7

Contents?: true

Size: 742 Bytes

Versions: 8

Compression:

Stored size: 742 Bytes

Contents

module Barometer
  module Query
    module Service
      class GoogleGeocode
        class Api < Utils::Api
          def url
            'http://maps.googleapis.com/maps/api/geocode/json'
          end

          def params
            format_params
          end

          def unwrap_nodes
            ['results', 0]
          end

          private

          def format_params
            params = { sensor: 'false' }
            params[:region] = query.geo.country_code if query.geo.country_code

            if query.format == :coordinates
              params[:latlng] = query.q.dup
            else
              params[:address] = query.q.dup
            end
            params
          end
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
barometer-0.9.7 lib/barometer/query/services/apis/google_geocode.rb
barometer-0.9.6 lib/barometer/query/services/apis/google_geocode.rb
barometer-0.9.5 lib/barometer/query/services/apis/google_geocode.rb
barometer-0.9.4 lib/barometer/query/services/apis/google_geocode.rb
barometer-0.9.3 lib/barometer/query/services/apis/google_geocode.rb
barometer-0.9.2 lib/barometer/query/services/apis/google_geocode.rb
barometer-0.9.1 lib/barometer/query/services/apis/google_geocode.rb
barometer-0.9.0 lib/barometer/query/services/apis/google_geocode.rb