simple_weather 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/simple_weather.rb +14 -14
- metadata +1 -1
data/lib/simple_weather.rb
CHANGED
@@ -2,9 +2,9 @@ require 'rubygems'
|
|
2
2
|
require 'json'
|
3
3
|
require 'net/http'
|
4
4
|
|
5
|
-
'7b1e71b12f5535c0'
|
5
|
+
#'7b1e71b12f5535c0'
|
6
6
|
module SimpleWeather
|
7
|
-
def updateWeather(
|
7
|
+
def updateWeather(conditions, city = 'MD/College Park')
|
8
8
|
base_url = 'http://api.wunderground.com/api/'
|
9
9
|
API_KEY = '7b1e71b12f5535c0'
|
10
10
|
query = '/conditions/q/'
|
@@ -14,31 +14,31 @@ module SimpleWeather
|
|
14
14
|
res = Net::HTTP.get_response(URI(url))
|
15
15
|
data = res.body if res.is_a?(Net::HTTPSuccess)
|
16
16
|
|
17
|
-
|
17
|
+
conditions = JSON.parse(data)
|
18
18
|
|
19
|
-
if
|
19
|
+
if conditions.has_key? 'error'
|
20
20
|
raise 'Web service error'
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
def getImageUrl(
|
25
|
-
|
24
|
+
def getImageUrl(conditions)
|
25
|
+
conditions['current_observation']['icon_url']
|
26
26
|
end
|
27
27
|
|
28
|
-
def getWeather(
|
29
|
-
|
28
|
+
def getWeather(conditions)
|
29
|
+
conditions['current_observation']['weather']
|
30
30
|
end
|
31
31
|
|
32
|
-
def getTemp_f(
|
33
|
-
|
32
|
+
def getTemp_f(conditions)
|
33
|
+
conditions['current_observation']['temp_f']
|
34
34
|
end
|
35
35
|
|
36
|
-
def getTemp_c(
|
37
|
-
|
36
|
+
def getTemp_c(conditions)
|
37
|
+
conditions['current_observation']['temp_c']
|
38
38
|
end
|
39
39
|
|
40
|
-
def getFeelsLike(
|
41
|
-
|
40
|
+
def getFeelsLike(conditions)
|
41
|
+
conditions['current_observation']['fellslike_string']
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|