Class: Decorators::OpenWeatherResponse
- Inherits:
-
Object
- Object
- Decorators::OpenWeatherResponse
- Defined in:
- lib/decorators/open_weather_response.rb
Instance Method Summary collapse
- #amount_in_kelvins ⇒ Object
-
#initialize(data) ⇒ OpenWeatherResponse
constructor
A new instance of OpenWeatherResponse.
- #parsed_data ⇒ Object
- #parsed_weather_description ⇒ Object
Constructor Details
#initialize(data) ⇒ OpenWeatherResponse
Returns a new instance of OpenWeatherResponse.
3 4 5 |
# File 'lib/decorators/open_weather_response.rb', line 3 def initialize(data) @data = data end |
Instance Method Details
#amount_in_kelvins ⇒ Object
7 8 9 |
# File 'lib/decorators/open_weather_response.rb', line 7 def amount_in_kelvins parsed_data['temp'].round(1) end |
#parsed_data ⇒ Object
11 12 13 |
# File 'lib/decorators/open_weather_response.rb', line 11 def parsed_data JSON.parse(data.body)['main'] end |
#parsed_weather_description ⇒ Object
15 16 17 |
# File 'lib/decorators/open_weather_response.rb', line 15 def parsed_weather_description JSON.parse(data.body)['weather'].first['description'].split.map(&:capitalize).join(' ') end |