simple_weather 0.0.5 → 0.0.6

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 +35 -49
  2. metadata +1 -1
@@ -3,57 +3,43 @@ require 'json'
3
3
  require 'net/http'
4
4
 
5
5
  '7b1e71b12f5535c0'
6
- module SimpleWeather::Weather
7
-
8
- def self.start_new
9
- Weather.start_new
10
- end
11
-
12
- class Weather
13
- def initialize
14
- @conditions = {}
15
- end
16
-
17
- def self.start_new
18
- w = self.new
19
- w
20
- end
21
-
22
- def updateWeather(city = 'MD/College Park')
23
- base_url = 'http://api.wunderground.com/api/'
24
- API_KEY = '7b1e71b12f5535c0'
25
- query = '/conditions/q/'
26
- format = '.json'
27
-
28
- url = URI.escape(base_url << api_key << query << city << format)
29
- res = Net::HTTP.get_response(URI(url))
30
- data = res.body if res.is_a?(Net::HTTPSuccess)
31
-
32
- @conditions = JSON.parse(data)
33
-
34
- if @conditions.has_key? 'error'
35
- raise 'Web service error'
36
- end
37
- end
6
+ module SimpleWeather
7
+ def updateWeather(@conditions, city = 'MD/College Park')
8
+ base_url = 'http://api.wunderground.com/api/'
9
+ API_KEY = '7b1e71b12f5535c0'
10
+ query = '/conditions/q/'
11
+ format = '.json'
38
12
 
39
- def getImageUrl
40
- @conditions['current_observation']['icon_url']
41
- end
42
-
43
- def getWeather
44
- @conditions['current_observation']['weather']
45
- end
46
-
47
- def getTemp_f
48
- @conditions['current_observation']['temp_f']
49
- end
50
-
51
- def getTemp_c
52
- @conditions['current_observation']['temp_c']
53
- end
13
+ url = URI.escape(base_url << api_key << query << city << format)
14
+ res = Net::HTTP.get_response(URI(url))
15
+ data = res.body if res.is_a?(Net::HTTPSuccess)
16
+
17
+ @conditions = JSON.parse(data)
54
18
 
55
- def getFeelsLike
56
- @conditions['current_observation']['fellslike_string']
19
+ if @conditions.has_key? 'error'
20
+ raise 'Web service error'
57
21
  end
58
22
  end
23
+
24
+ def getImageUrl(@conditions)
25
+ @conditions['current_observation']['icon_url']
26
+ end
27
+
28
+ def getWeather(@conditions)
29
+ @conditions['current_observation']['weather']
30
+ end
31
+
32
+ def getTemp_f(@conditions)
33
+ @conditions['current_observation']['temp_f']
34
+ end
35
+
36
+ def getTemp_c(@conditions)
37
+ @conditions['current_observation']['temp_c']
38
+ end
39
+
40
+ def getFeelsLike(@conditions)
41
+ @conditions['current_observation']['fellslike_string']
42
+ end
59
43
  end
44
+
45
+ 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.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: