Class: YahooWeather::Atmosphere
- Inherits:
-
Object
- Object
- YahooWeather::Atmosphere
- Defined in:
- lib/yahoo-weather/atmosphere.rb
Overview
Describes the specific atmospheric conditions at a location.
Defined Under Namespace
Classes: Barometer
Instance Attribute Summary collapse
-
#barometer ⇒ Object
readonly
the state of the barometer, defined as one of the YahooWeather::Atmosphere::Barometer constants.
-
#humidity ⇒ Object
readonly
the humidity of the surroundings.
-
#pressure ⇒ Object
readonly
the pressure level of the surroundings.
-
#visibility ⇒ Object
readonly
the visibility level of the surroundings.
Instance Method Summary collapse
-
#initialize(payload) ⇒ Atmosphere
constructor
A new instance of Atmosphere.
Constructor Details
#initialize(payload) ⇒ Atmosphere
Returns a new instance of Atmosphere.
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/yahoo-weather/atmosphere.rb', line 27 def initialize (payload) @humidity = payload['humidity'].to_i @visibility = payload['visibility'].to_i @pressure = payload['pressure'].to_f # map barometric pressure direction to appropriate constant @barometer = nil case payload['rising'].to_i when 0 then @barometer = Barometer::STEADY when 1 then @barometer = Barometer::RISING when 2 then @barometer = Barometer::FALLING end end |
Instance Attribute Details
#barometer ⇒ Object (readonly)
the state of the barometer, defined as one of the YahooWeather::Atmosphere::Barometer constants.
25 26 27 |
# File 'lib/yahoo-weather/atmosphere.rb', line 25 def @barometer end |
#humidity ⇒ Object (readonly)
the humidity of the surroundings.
15 16 17 |
# File 'lib/yahoo-weather/atmosphere.rb', line 15 def humidity @humidity end |
#pressure ⇒ Object (readonly)
the pressure level of the surroundings.
21 22 23 |
# File 'lib/yahoo-weather/atmosphere.rb', line 21 def pressure @pressure end |
#visibility ⇒ Object (readonly)
the visibility level of the surroundings
18 19 20 |
# File 'lib/yahoo-weather/atmosphere.rb', line 18 def visibility @visibility end |