Class: Forecast::Adapters::WundergroundAdapter
- Inherits:
-
Object
- Object
- Forecast::Adapters::WundergroundAdapter
show all
- Includes:
- Forecast::Adapter
- Defined in:
- lib/forecast/adapters/wunderground_adapter.rb
Instance Method Summary
collapse
included, #initialize, instance
Instance Method Details
#current(latitude, longitude) ⇒ Object
7
8
9
10
11
12
13
14
|
# File 'lib/forecast/adapters/wunderground_adapter.rb', line 7
def current(latitude, longitude)
forecast = nil
result = get_json(get_action('conditions', latitude, longitude))
if result.has_key?('current_observation')
forecast = get_current_forecast(result['current_observation'].merge({latitude: latitude, longitude: longitude}))
end
return forecast
end
|
#daily(latitude, longitude) ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/forecast/adapters/wunderground_adapter.rb', line 29
def daily(latitude, longitude)
forecasts = Forecast::Collection.new
result = get_json(get_action('forecast', latitude, longitude))
if result.has_key?('forecast')
items = result['forecast']['simpleforecast']['forecastday']
items.each do |hash|
forecast = get_daily_forecast(hash.merge({latitude: latitude, longitude: longitude}))
forecasts << forecast
end
end
return forecasts
end
|
#hourly(latitude, longitude) ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/forecast/adapters/wunderground_adapter.rb', line 16
def hourly(latitude, longitude)
forecasts = Forecast::Collection.new
result = get_json(get_action('hourly', latitude, longitude))
if result.has_key?('hourly_forecast')
items = result['hourly_forecast']
items.each do |hash|
forecast = get_hourly_forecast(hash.merge({latitude: latitude, longitude: longitude}))
forecasts << forecast
end
end
return forecasts
end
|