Class: OpenWeatherMapApi

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

Class Method Summary collapse

Class Method Details

.get_forecast(options = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/open_weather_map_api.rb', line 7

def get_forecast(options = {})
  @path = "forecast"
  @query = build_query(options)
  begin
    if response.is_a?(Net::HTTPSuccess)
      return JSON.parse(response.body)
    end
  rescue
    return nil
  end
end

.get_weather(options = {}) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/open_weather_map_api.rb', line 19

def get_weather(options = {})
  @path = "weather"
  @query = build_query(options)
  begin
    if response.is_a?(Net::HTTPSuccess)
      return JSON.parse(response.body)
    end
  rescue => err
    return nil
  end
end