Class: Forecast::Adapters::ForecastIoAdapter

Inherits:
Object
  • Object
show all
Includes:
Forecast::Adapter
Defined in:
lib/forecast/adapters/forecast_io_adapter.rb

Instance Method Summary collapse

Methods included from Forecast::Adapter

included, #initialize, instance

Instance Method Details

#current(latitude, longitude) ⇒ Object



7
8
9
10
# File 'lib/forecast/adapters/forecast_io_adapter.rb', line 7

def current(latitude, longitude)
  result = get_json(get_action(latitude, longitude))
  get_forecast({latitude: latitude, longitude: longitude}.merge(result['currently'])) unless nil
end

#daily(latitude, longitude) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/forecast/adapters/forecast_io_adapter.rb', line 21

def daily(latitude, longitude)
  result = get_json(get_action(latitude, longitude))
  forecasts = Forecast::Collection.new
  result['daily']['data'].each do |hash|
    forecasts << get_forecast({latitude: latitude, longitude: longitude}.merge(hash))
  end
  return forecasts
end

#hourly(latitude, longitude) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/forecast/adapters/forecast_io_adapter.rb', line 12

def hourly(latitude, longitude)
  result = get_json(get_action(latitude, longitude))
  forecasts = Forecast::Collection.new
  result['hourly']['data'].each do |hash|
    forecasts << get_forecast({latitude: latitude, longitude: longitude}.merge(hash))
  end
  return forecasts
end