Class: YahooWeather::Atmosphere

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#barometerObject (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
  @barometer
end

#humidityObject (readonly)

the humidity of the surroundings.



15
16
17
# File 'lib/yahoo-weather/atmosphere.rb', line 15

def humidity
  @humidity
end

#pressureObject (readonly)

the pressure level of the surroundings.



21
22
23
# File 'lib/yahoo-weather/atmosphere.rb', line 21

def pressure
  @pressure
end

#visibilityObject (readonly)

the visibility level of the surroundings



18
19
20
# File 'lib/yahoo-weather/atmosphere.rb', line 18

def visibility
  @visibility
end