Class: Decorators::OpenWeatherResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/decorators/open_weather_response.rb

Instance Method Summary collapse

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_kelvinsObject



7
8
9
# File 'lib/decorators/open_weather_response.rb', line 7

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

#parsed_dataObject



11
12
13
# File 'lib/decorators/open_weather_response.rb', line 11

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

#parsed_weather_descriptionObject



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