simple_weather 0.0.2 → 0.0.3

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 +34 -55
  2. metadata +2 -2
@@ -4,25 +4,9 @@ require 'net/http'
4
4
 
5
5
  # api key from wunderground: 7b1e71b12f5535c0
6
6
  module SimpleWeather
7
- class << self
8
- attr_accessor :configuration
9
- end
10
-
11
- def self.configuration
12
- @configuration ||= Configuration.new
13
- end
14
-
15
- def self.configure
16
- yield(configuration)
17
- end
18
-
19
- class Configuration
20
- attr_accessor :last_update, :conditions
21
-
22
- def initialize
23
- @last_update = Time.now
24
- @conditions = {}
25
- end
7
+ def self.initialize
8
+ @last_update = Time.now
9
+ @conditions = {}
26
10
  end
27
11
 
28
12
  def self.included(base)
@@ -31,46 +15,41 @@ module SimpleWeather
31
15
  base.send :include, InstanceMethods
32
16
  end
33
17
 
34
- module ClassMethods
35
- end
36
-
37
- module InstanceMethods
38
- def updateWeather(city = 'MD/College Park')
39
- base_url = 'http://api.wunderground.com/api/'
40
- api_key = '7b1e71b12f5535c0'
41
- query = '/conditions/q/'
42
- format = '.json'
43
-
44
- url = URI.escape(base_url << api_key << query << city << format)
45
- res = Net::HTTP.get_response(URI(url))
46
- data = res.body if res.is_a?(Net::HTTPSuccess)
47
-
48
- @conditions = JSON.parse(data)
49
-
50
- if @conditions.has_key? 'error'
51
- raise 'Web service error'
52
- end
53
- end
54
-
55
- def getImageUrl
56
- @conditions['current_observation']['icon_url']
57
- end
18
+ def self.updateWeather(city = 'MD/College Park')
19
+ base_url = 'http://api.wunderground.com/api/'
20
+ api_key = '7b1e71b12f5535c0'
21
+ query = '/conditions/q/'
22
+ format = '.json'
58
23
 
59
- def getWeather
60
- @conditions['current_observation']['weather']
61
- end
62
-
63
- def getTemp_f
64
- @conditions['current_observation']['temp_f']
65
- end
24
+ url = URI.escape(base_url << api_key << query << city << format)
25
+ res = Net::HTTP.get_response(URI(url))
26
+ data = res.body if res.is_a?(Net::HTTPSuccess)
27
+
28
+ @conditions = JSON.parse(data)
66
29
 
67
- def getTemp_c
68
- @conditions['current_observation']['temp_c']
30
+ if @conditions.has_key? 'error'
31
+ raise 'Web service error'
69
32
  end
33
+ end
70
34
 
71
- def getFeelsLike
72
- @conditions['current_observation']['fellslike_string']
73
- end
35
+ def self.getImageUrl
36
+ @conditions['current_observation']['icon_url']
37
+ end
38
+
39
+ def self.getWeather
40
+ @conditions['current_observation']['weather']
41
+ end
42
+
43
+ def self.getTemp_f
44
+ @conditions['current_observation']['temp_f']
45
+ end
46
+
47
+ def self.getTemp_c
48
+ @conditions['current_observation']['temp_c']
49
+ end
50
+
51
+ def self.getFeelsLike
52
+ @conditions['current_observation']['fellslike_string']
74
53
  end
75
54
  end
76
55
 
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.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-11 00:00:00.000000000 Z
12
+ date: 2012-08-12 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: A simple weather gem
15
15
  email: ye.yicheng123@gmail.com