class OpenWeatherApi::OpenWeatherApi
Constants
- URL
Public Class Methods
new(options = {})
click to toggle source
# File lib/open_weather_api/open_weather_api.rb, line 10 def initialize(options = {}) @options = options end
Public Instance Methods
forecast()
click to toggle source
# File lib/open_weather_api/open_weather_api.rb, line 21 def forecast url = URL+'forecast' @forecast = ::OpenWeatherApi::Forecast.new.from_json(get(url, @options).body) @forecast.params = @options @forecast end
weather()
click to toggle source
# File lib/open_weather_api/open_weather_api.rb, line 14 def weather url = URL+'weather' @weather = ::OpenWeatherApi::Weather.new.from_json(get(url, @options).body) @weather.params = @options @weather end
Protected Instance Methods
get(url, params)
click to toggle source
# File lib/open_weather_api/open_weather_api.rb, line 30 def get(url, params) Faraday.get(url) do |req| params.each do |key, value| req.params[key] = value end req.headers['Accept'] = 'application/json' end end