yahoo-weather 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.rdoc CHANGED
@@ -1,3 +1,11 @@
1
+ = YAHOO_WEATHER_20091209_1_1_0
2
+
3
+ * [shaper] revise atmosphere.barometer to reflect tri-state as
4
+ "steady", "rising", or "falling" via one of the new
5
+ YahooWeather::Atmosphere::Barometer constants, whereas previously it
6
+ was simply a boolean for whether rising. Thanks to Andy Weber for
7
+ suggestion.
8
+
1
9
  = YAHOO_WEATHER_20091021_1_0_1
2
10
 
3
11
  * [shaper] update documentation to reflect reality and use suffix for
data/README.rdoc CHANGED
@@ -30,7 +30,7 @@ Then install the gem by executing:
30
30
 
31
31
  == Usage
32
32
 
33
- A simple example program under +examples/example.rb+ as:
33
+ A simple example program:
34
34
 
35
35
  require 'rubygems'
36
36
  require 'yahoo-weather'
@@ -83,6 +83,6 @@ This library is provided via the GNU LGPL license at http://www.gnu.org/licenses
83
83
  == Author
84
84
 
85
85
  Copyright 2006 - 2009, Walter Korman <shaper@fatgoose.com>,
86
- http://www.lemurware.com.
86
+ http://lemurware.blogspot.com.
87
87
 
88
88
  Thanks to Matthew Berk for inspiration and initial hack.
data/lib/yahoo-weather.rb CHANGED
@@ -16,13 +16,12 @@
16
16
  # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
17
 
18
18
  require 'net/http'
19
- require 'pp'
20
19
  require 'time'
21
20
  require 'xmlsimple'
22
21
 
23
22
  class YahooWeather
24
23
 
25
- VERSION = '1.0.1'
24
+ VERSION = '1.1.0'
26
25
 
27
26
  # Describes astronomy information for a particular location.
28
27
  class Astronomy
@@ -98,6 +97,17 @@ class YahooWeather
98
97
 
99
98
  # Describes the specific atmospheric conditions at a location.
100
99
  class Atmosphere
100
+ # Constants representing the state of the barometric pressure.
101
+ #
102
+ class Barometer
103
+ STEADY = 'steady'
104
+ RISING = 'rising'
105
+ FALLING = 'falling'
106
+
107
+ # lists all possible barometer constants
108
+ ALL = [ STEADY, RISING, FALLING ]
109
+ end
110
+
101
111
  # the humidity of the surroundings.
102
112
  attr_reader :humidity
103
113
 
@@ -107,14 +117,22 @@ class YahooWeather
107
117
  # the pressure level of the surroundings.
108
118
  attr_reader :pressure
109
119
 
110
- # whether the air currents are rising.
111
- attr_reader :rising
112
-
120
+ # the state of the barometer, defined as one of the
121
+ # YahooWeather::Atmosphere::Barometer constants.
122
+ attr_reader :barometer
123
+
113
124
  def initialize (payload)
114
125
  @humidity = payload['humidity'].to_i
115
126
  @visibility = payload['visibility'].to_i
116
127
  @pressure = payload['pressure'].to_f
117
- @rising = (payload['rising'] == "1")
128
+
129
+ # map barometric pressure direction to appropriate constant
130
+ @barometer = nil
131
+ case payload['rising'].to_i
132
+ when 0: @barometer = Barometer::STEADY
133
+ when 1: @barometer = Barometer::RISING
134
+ when 2: @barometer = Barometer::FALLING
135
+ end
118
136
  end
119
137
  end
120
138
 
data/test/test_api.rb CHANGED
@@ -72,7 +72,7 @@ class TestAPI < Test::Unit::TestCase
72
72
  assert_kind_of Numeric, response.atmosphere.humidity
73
73
  assert_kind_of Numeric, response.atmosphere.visibility
74
74
  assert_kind_of Numeric, response.atmosphere.pressure
75
- assert(response.atmosphere.rising.is_a?(TrueClass) || response.atmosphere.rising.is_a?(FalseClass))
75
+ assert(YahooWeather::Atmosphere::Barometer::ALL.include?(response.atmosphere.barometer))
76
76
 
77
77
  # check the condition info
78
78
  assert_instance_of YahooWeather::Condition, response.condition
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yahoo-weather
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Walter Korman
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-10-21 00:00:00 -07:00
12
+ date: 2009-12-09 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency