Sha256: 88172d491b6efdefe769cce6890c2df693967711a8de45a20258750098bdad3f

Contents?: true

Size: 691 Bytes

Versions: 8

Compression:

Stored size: 691 Bytes

Contents

module Barometer
  module Query
    module Converter
      class ToGeocode
        def self.from
          [:short_zipcode, :zipcode, :postalcode, :coordinates, :icao, :unknown]
        end

        def initialize(query)
          @query = query
        end

        def call
          return unless can_convert?

          @query.geo = @query.geo.merge( Service::GoogleGeocode.new(@query).call )
          @query.add_conversion(:geocode, @query.geo.to_s)
        end

        private

        def can_convert?
          !!@query.get_conversion(*self.class.from)
        end
      end
    end
  end
end

Barometer::Query::Converter.register(:geocode, Barometer::Query::Converter::ToGeocode)

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
barometer-0.9.7 lib/barometer/query/converters/to_geocode.rb
barometer-0.9.6 lib/barometer/query/converters/to_geocode.rb
barometer-0.9.5 lib/barometer/query/converters/to_geocode.rb
barometer-0.9.4 lib/barometer/query/converters/to_geocode.rb
barometer-0.9.3 lib/barometer/query/converters/to_geocode.rb
barometer-0.9.2 lib/barometer/query/converters/to_geocode.rb
barometer-0.9.1 lib/barometer/query/converters/to_geocode.rb
barometer-0.9.0 lib/barometer/query/converters/to_geocode.rb