diff --git a/lib/open_weather_api/base.rb b/lib/open_weather_api/base.rb index 61ca01e..13b401d 100644 --- a/lib/open_weather_api/base.rb +++ b/lib/open_weather_api/base.rb @@ -1,3 +1,5 @@ +#Base class with functions common to all other classes + require 'httparty' require 'addressable/uri' module OpenWeather diff --git a/lib/open_weather_api/current_weather.rb b/lib/open_weather_api/current_weather.rb index 02fb6de..0ea158b 100644 --- a/lib/open_weather_api/current_weather.rb +++ b/lib/open_weather_api/current_weather.rb @@ -3,12 +3,33 @@ class Current < Base @api_url = 'http://api.openweathermap.org/data/2.5/weather' - #format : Cochin,IN + #City format : Eg, Cochin,IN + #Useage: OpenWeather::Current.city('Cochin,In') def self.city(city, options = { }) query = Hash.new query[:q] = city send_request query.merge!(options), @api_url end + + #City Geographics Cordingates : Eg, lat 35 lon 139 + + def self.geographic_cordinate(lat, lon, options = {}) + query = Hash.new + query[:lat] = lat + query[:lon] = lon + send_request query.merge!(options), @api_url + end + + alias :geographic_cordinate :geocode + + #City Id, an integer value. Eg, 2172797 + #Useage: OpenWeather::Current.city_id(2172797) + + def self.city_id(city_id, options = {}) + query = Hash.new + query[:id] = city_id + send_request query.merge!(options), @api_url + end end end