simple_weather 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/simple_weather.rb +14 -13
- metadata +1 -1
data/lib/simple_weather.rb
CHANGED
@@ -2,23 +2,26 @@ require 'rubygems'
|
|
2
2
|
require 'json'
|
3
3
|
require 'net/http'
|
4
4
|
|
5
|
-
|
6
|
-
module SimpleWeather
|
5
|
+
'7b1e71b12f5535c0'
|
6
|
+
module SimpleWeather::Weather
|
7
|
+
|
8
|
+
def self.start_new
|
9
|
+
Weather.start_new
|
10
|
+
end
|
11
|
+
|
7
12
|
class Weather
|
8
13
|
def initialize
|
9
|
-
@last_update = Time.now
|
10
14
|
@conditions = {}
|
11
15
|
end
|
12
|
-
|
13
|
-
def
|
14
|
-
|
15
|
-
|
16
|
-
base.send :include, InstanceMethods
|
16
|
+
|
17
|
+
def self.start_new
|
18
|
+
w = self.new
|
19
|
+
w
|
17
20
|
end
|
18
21
|
|
19
22
|
def updateWeather(city = 'MD/College Park')
|
20
23
|
base_url = 'http://api.wunderground.com/api/'
|
21
|
-
|
24
|
+
API_KEY = '7b1e71b12f5535c0'
|
22
25
|
query = '/conditions/q/'
|
23
26
|
format = '.json'
|
24
27
|
|
@@ -31,8 +34,8 @@ module SimpleWeather
|
|
31
34
|
if @conditions.has_key? 'error'
|
32
35
|
raise 'Web service error'
|
33
36
|
end
|
34
|
-
end
|
35
|
-
|
37
|
+
end
|
38
|
+
|
36
39
|
def getImageUrl
|
37
40
|
@conditions['current_observation']['icon_url']
|
38
41
|
end
|
@@ -54,5 +57,3 @@ module SimpleWeather
|
|
54
57
|
end
|
55
58
|
end
|
56
59
|
end
|
57
|
-
|
58
|
-
ActionView::Base.send(:include, SimpleWeather) if defined?(ActionView::Base)
|