File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change
1
+ #Base class with functions common to all other classes
2
+
1
3
require 'httparty'
2
4
require 'addressable/uri'
3
5
module OpenWeather
Original file line number Diff line number Diff line change @@ -3,12 +3,33 @@ class Current < Base
3
3
4
4
@api_url = 'http://api.openweathermap.org/data/2.5/weather'
5
5
6
- #format : Cochin,IN
6
+ #City format : Eg, Cochin,IN
7
+ #Useage: OpenWeather::Current.city('Cochin,In')
7
8
def self . city ( city , options = { } )
8
9
query = Hash . new
9
10
query [ :q ] = city
10
11
send_request query . merge! ( options ) , @api_url
11
12
end
13
+
14
+ #City Geographics Cordingates : Eg, lat 35 lon 139
15
+
16
+ def self . geographic_cordinate ( lat , lon , options = { } )
17
+ query = Hash . new
18
+ query [ :lat ] = lat
19
+ query [ :lon ] = lon
20
+ send_request query . merge! ( options ) , @api_url
21
+ end
22
+
23
+ alias :geographic_cordinate :geocode
24
+
25
+ #City Id, an integer value. Eg, 2172797
26
+ #Useage: OpenWeather::Current.city_id(2172797)
27
+
28
+ def self . city_id ( city_id , options = { } )
29
+ query = Hash . new
30
+ query [ :id ] = city_id
31
+ send_request query . merge! ( options ) , @api_url
32
+ end
12
33
end
13
34
end
14
35
You can’t perform that action at this time.
0 commit comments