Sha256: e3735d8d9dfeecc6530e0e440e147072aac3ad306ffa7cae8ba73471e0e53650

Contents?: true

Size: 816 Bytes

Versions: 6

Compression:

Stored size: 816 Bytes

Contents

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

          private

          attr_reader :location

          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
            location.latitude
          end

          def longitude
            location.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_location.rb
barometer-0.9.4 lib/barometer/weather_services/noaa/response/current_location.rb
barometer-0.9.3 lib/barometer/weather_services/noaa/response/current_location.rb
barometer-0.9.2 lib/barometer/weather_services/noaa/response/current_location.rb
barometer-0.9.1 lib/barometer/weather_services/noaa/response/current_location.rb
barometer-0.9.0 lib/barometer/weather_services/noaa/response/current_location.rb