From 8f216a376004b52e6caf1779e34e30ab7f35e3c6 Mon Sep 17 00:00:00 2001 From: ernepriv Date: Wed, 23 Nov 2016 13:25:00 +0100 Subject: [PATCH] Update weather-api.rb I modified this for let me use city and state and no WOEID --- lib/weather-api.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/weather-api.rb b/lib/weather-api.rb index 834d052..4e6ee43 100644 --- a/lib/weather-api.rb +++ b/lib/weather-api.rb @@ -34,12 +34,12 @@ class << self # Weather::Units::CELSIUS constants. Defaults to Celsius # # Returns a Weather::Response object containing forecast - def lookup(woeid, unit = Units::CELSIUS) + def lookup(city,state, unit = Units::CELSIUS) acceptable_units = [Units::CELSIUS, Units::FAHRENHEIT] unit = Units::CELSIUS unless acceptable_units.include?(unit) url = ROOT + "?q=select%20*%20from%20weather.forecast%20" - url += "where%20woeid%3D#{woeid}%20and%20u%3D'#{unit}'&format=json" + url += "where%20woeid%%20in%20(select%20woeid%20from%20geo.places(1)%20where%20text%3D%22#{city}%2C%20#{state}%22)%20and%20u%3D'#{unit}'&format=json" doc = get_response url Response.new woeid, url, doc