Module: LitaForecast::Weather

Included in:
Lita::Handlers::Forecast
Defined in:
lib/lita/handlers/forecast/weather.rb

Overview

Module

Instance Method Summary collapse

Instance Method Details

#weather(response, api_key, units = 'us') ⇒ Object



18
19
20
21
22
23
# File 'lib/lita/handlers/forecast/weather.rb', line 18

def weather(response, api_key, units = 'us')
  location = LitaForecast::Location.new(LitaForecast.redis)
    .find_location(response.args.join(' '))
  f = weather_forecast(api_key, location.merge(params: { units: units }))
  LitaForecast::Response.new(f, location[:desc]).generate
end

#weather_forecast(api_key, l = {}) ⇒ Object



12
13
14
15
16
# File 'lib/lita/handlers/forecast/weather.rb', line 12

def weather_forecast(api_key, l = {})
  ForecastIO.api_key = api_key
  l = { params: { exclude: 'alerts' } }.merge(l)
  ForecastIO.forecast(l[:lat].to_f, l[:lng].to_f, params: l[:params])
end