simple_weather 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/simple_weather.rb +38 -32
  2. metadata +1 -1
@@ -8,41 +8,47 @@ module SimpleWeather
8
8
  class << self
9
9
  end
10
10
 
11
- def updateWeather(conditions, city = 'MD/College Park')
12
- base_url = 'http://api.wunderground.com/api/'
13
- api_key = '7b1e71b12f5535c0'
14
- query = '/conditions/q/'
15
- format = '.json'
16
-
17
- url = URI.escape(base_url << api_key << query << city << format)
18
- res = Net::HTTP.get_response(URI(url))
19
- data = res.body if res.is_a?(Net::HTTPSuccess)
11
+ def self.included(base)
12
+ base.send :include, InstanceMethods
13
+ end
14
+
15
+ module InstanceMethods
16
+ def updateWeather(conditions, city = 'MD/College Park')
17
+ base_url = 'http://api.wunderground.com/api/'
18
+ api_key = '7b1e71b12f5535c0'
19
+ query = '/conditions/q/'
20
+ format = '.json'
21
+
22
+ url = URI.escape(base_url << api_key << query << city << format)
23
+ res = Net::HTTP.get_response(URI(url))
24
+ data = res.body if res.is_a?(Net::HTTPSuccess)
20
25
 
21
- conditions = JSON.parse(data)
26
+ conditions = JSON.parse(data)
27
+
28
+ if conditions.has_key? 'error'
29
+ raise 'Web service error'
30
+ end
31
+ end
32
+
33
+ def getImageUrl(conditions)
34
+ conditions['current_observation']['icon_url']
35
+ end
22
36
 
23
- if conditions.has_key? 'error'
24
- raise 'Web service error'
37
+ def getWeather(conditions)
38
+ conditions['current_observation']['weather']
39
+ end
40
+
41
+ def getTemp_f(conditions)
42
+ conditions['current_observation']['temp_f']
43
+ end
44
+
45
+ def getTemp_c(conditions)
46
+ conditions['current_observation']['temp_c']
47
+ end
48
+
49
+ def getFeelsLike(conditions)
50
+ conditions['current_observation']['fellslike_string']
25
51
  end
26
- end
27
-
28
- def getImageUrl(conditions)
29
- conditions['current_observation']['icon_url']
30
- end
31
-
32
- def getWeather(conditions)
33
- conditions['current_observation']['weather']
34
- end
35
-
36
- def getTemp_f(conditions)
37
- conditions['current_observation']['temp_f']
38
- end
39
-
40
- def getTemp_c(conditions)
41
- conditions['current_observation']['temp_c']
42
- end
43
-
44
- def getFeelsLike(conditions)
45
- conditions['current_observation']['fellslike_string']
46
52
  end
47
53
  end
48
54
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_weather
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: