Method: OWMO::WeatherResponse#initialize
- Defined in:
- lib/owmo/weather_response.rb
#initialize(http_response) ⇒ WeatherResponse
Returns a new instance of WeatherResponse.
10 11 12 13 14 15 16 17 18 |
# File 'lib/owmo/weather_response.rb', line 10 def initialize(http_response) # JSON @weather = JSON.parse(http_response.body) @code = parse_code rescue JSON::ParserError, TypeError # Assume XML or HTML @weather = http_response.body @code = weather.length > 10 ? 200 : 500 end |