Sha256: 08033ed7fda0de84d54e6b616d360ca0c92b675cd7851c3ae7e723dfc705e5f1

Contents?: true

Size: 417 Bytes

Versions: 1

Compression:

Stored size: 417 Bytes

Contents

module Decorators
  class OpenWeatherResponse
    def initialize(data)
      @data = data
    end

    def amount_in_kelvins
      parsed_data['temp'].round(1)
    end

    def parsed_data
      JSON.parse(data.body)['main']
    end

    def parsed_weather_description
      JSON.parse(data.body)['weather'].first['description'].split.map(&:capitalize).join(' ')
    end

    private

    attr_reader :data
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
weather_handler-0.1.2 lib/decorators/open_weather_response.rb