Sha256: fc571b187be9d2725f1b7cc0732f51b3185cd3c44adaa48ed79f882084e159df

Contents?: true

Size: 659 Bytes

Versions: 7

Compression:

Stored size: 659 Bytes

Contents

module Barometer
  module Query
    module Converter
      class FromCoordinatesToNoaaStationId
        def self.from
          [:coordinates]
        end

        def initialize(query)
          @query = query
        end

        def call
          return unless can_convert?

          station_id = Service::NoaaStation.fetch(@query)
          @query.add_conversion(:noaa_station_id, station_id)
        end

        private

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

Barometer::Query::Converter.register(:coordinates, Barometer::Query::Converter::FromCoordinatesToNoaaStationId)

Version data entries

7 entries across 7 versions & 1 rubygems

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