Class: Weather::Atmosphere
- Inherits:
-
Object
- Object
- Weather::Atmosphere
- Defined in:
- lib/weather-api/atmosphere.rb
Defined Under Namespace
Classes: Barometer
Instance Attribute Summary collapse
-
#barometer ⇒ Object
readonly
barometer state, defined as one of the contants in Weather::Atmosphere::Barometer.
-
#humidity ⇒ Object
readonly
air humidity.
-
#pressure ⇒ Object
readonly
air pressure level.
-
#visibility ⇒ Object
readonly
visibility 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.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/weather-api/atmosphere.rb', line 25 def initialize(payload) @humidity = payload[:humidity].to_i @visibility = payload[:visibility].to_i @pressure = payload[:pressure].to_f # map barometric pressure 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)
barometer state, defined as one of the contants in Weather::Atmosphere::Barometer
23 24 25 |
# File 'lib/weather-api/atmosphere.rb', line 23 def @barometer end |
#humidity ⇒ Object (readonly)
air humidity
13 14 15 |
# File 'lib/weather-api/atmosphere.rb', line 13 def humidity @humidity end |
#pressure ⇒ Object (readonly)
air pressure level
19 20 21 |
# File 'lib/weather-api/atmosphere.rb', line 19 def pressure @pressure end |
#visibility ⇒ Object (readonly)
visibility of the surroundings
16 17 18 |
# File 'lib/weather-api/atmosphere.rb', line 16 def visibility @visibility end |