Sha256: 172c7cf56d749b996667baad10f40b07e46baa6d8852762f20cafb458b60e656

Contents?: true

Size: 882 Bytes

Versions: 6

Compression:

Stored size: 882 Bytes

Contents

module Barometer
  module WeatherService
    class Noaa
      class Response
        class CurrentStation < WeatherService::Response::Location
          def initialize(payload, response)
            super(payload)
            @station = response.station
          end

          private

          attr_reader :station

          def id
            payload.fetch('station_id')
          end

          def name
            payload.fetch('location')
          end

          def city
            payload.using(/^(.*?),/).fetch('location')
          end

          def state_code
            payload.using(/,(.*?)$/).fetch('location')
          end

          def country_code
            'US'
          end

          def latitude
            station.latitude
          end

          def longitude
            station.longitude
          end
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
barometer-0.9.5 lib/barometer/weather_services/noaa/response/current_station.rb
barometer-0.9.4 lib/barometer/weather_services/noaa/response/current_station.rb
barometer-0.9.3 lib/barometer/weather_services/noaa/response/current_station.rb
barometer-0.9.2 lib/barometer/weather_services/noaa/response/current_station.rb
barometer-0.9.1 lib/barometer/weather_services/noaa/response/current_station.rb
barometer-0.9.0 lib/barometer/weather_services/noaa/response/current_station.rb