class WeatherForecaster::WeatherForecastApi
Public Class Methods
new()
click to toggle source
# File lib/weather_forecaster/weather_forecast_api.rb, line 7 def initialize @client = "http://api.openweathermap.org/data/2.5/forecast/daily" end
Public Instance Methods
query(city, count)
click to toggle source
# File lib/weather_forecaster/weather_forecast_api.rb, line 11 def query(city, count) result = {} begin status = Timeout::timeout(5){ result = HTTParty.get(@client, :query => {:q=> city, :cnt => count}) } rescue Timeout::Error => e puts "Taking too long time", :status => 500 return end return WeatherForecastResponse.new(result) if result end