simple_weather 0.0.0 → 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. data/lib/simple_weather.rb +40 -38
  2. metadata +1 -1
@@ -3,47 +3,49 @@ require 'json'
3
3
  require 'net/http'
4
4
 
5
5
  # api key from wunderground: 7b1e71b12f5535c0
6
-
7
- class Weather
8
- def initialize
9
- @last_update = Time.now
10
- @conditions = {}
11
- end
12
-
13
- def updateWeather(city = 'MD/College Park')
14
- base_url = 'http://api.wunderground.com/api/'
15
- api_key = '7b1e71b12f5535c0'
16
- query = '/conditions/q/'
17
- format = '.json'
6
+ module SimpleWeather
7
+ class Weather
8
+ def initialize
9
+ @last_update = Time.now
10
+ @conditions = {}
11
+ end
18
12
 
19
- url = URI.escape(base_url << api_key << query << city << format)
20
- res = Net::HTTP.get_response(URI(url))
21
- data = res.body if res.is_a?(Net::HTTPSuccess)
13
+ def updateWeather(city = 'MD/College Park')
14
+ base_url = 'http://api.wunderground.com/api/'
15
+ api_key = '7b1e71b12f5535c0'
16
+ query = '/conditions/q/'
17
+ format = '.json'
18
+
19
+ url = URI.escape(base_url << api_key << query << city << format)
20
+ res = Net::HTTP.get_response(URI(url))
21
+ data = res.body if res.is_a?(Net::HTTPSuccess)
22
22
 
23
- @conditions = JSON.parse(data)
23
+ @conditions = JSON.parse(data)
24
+
25
+ if @conditions.has_key? 'error'
26
+ raise 'Web service error'
27
+ end
28
+ end
29
+
30
+ def getImageUrl()
31
+ @conditions['current_observation']['icon_url']
32
+ end
24
33
 
25
- if @conditions.has_key? 'error'
26
- raise 'Web service error'
34
+ def getWeather()
35
+ @conditions['current_observation']['weather']
36
+ end
37
+
38
+ def getTemp_f()
39
+ @conditions['current_observation']['temp_f']
40
+ end
41
+
42
+ def getTemp_c()
43
+ @conditions['current_observation']['temp_c']
44
+ end
45
+
46
+ def getFeelsLike()
47
+ @conditions['current_observation']['fellslike_string']
27
48
  end
28
- end
29
-
30
- def getImageUrl()
31
- @conditions['current_observation']['icon_url']
32
- end
33
-
34
- def getWeather()
35
- @conditions['current_observation']['weather']
36
- end
37
-
38
- def getTemp_f()
39
- @conditions['current_observation']['temp_f']
40
- end
41
-
42
- def getTemp_c()
43
- @conditions['current_observation']['temp_c']
44
- end
45
-
46
- def getFeelsLike()
47
- @conditions['current_observation']['fellslike_string']
48
49
  end
49
50
  end
51
+ ActionView::Base.send(:include, SimpleWeather) if defined?(ActionView::Base)
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.0
4
+ version: 0.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: