simple_weather 0.0.10 → 0.0.11

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