Class: YahooWeather::Atmosphere

Inherits:
Object
  • Object
show all
Defined in:
lib/yahoo_weather/atmosphere.rb

Defined Under Namespace

Classes: Barometer

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(payload) ⇒ Atmosphere

Returns a new instance of Atmosphere.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/yahoo_weather/atmosphere.rb', line 13

def initialize(payload)
  @humidity = payload['humidity'].to_i
  @visibility = payload['visibility'].to_f
  @pressure = payload['pressure'].to_f

  # map barometric pressure direction to appropriate constant
  @barometer = nil
  case payload['rising'].to_i
  when 0
    @barometer = Barometer::STEADY
  when 1
    @barometer = Barometer::RISING
  when 2
    @barometer = Barometer::FALLING
  end
end

Instance Attribute Details

#barometerObject (readonly)

Returns the value of attribute barometer.



11
12
13
# File 'lib/yahoo_weather/atmosphere.rb', line 11

def barometer
  @barometer
end

#humidityObject (readonly)

Returns the value of attribute humidity.



11
12
13
# File 'lib/yahoo_weather/atmosphere.rb', line 11

def humidity
  @humidity
end

#pressureObject (readonly)

Returns the value of attribute pressure.



11
12
13
# File 'lib/yahoo_weather/atmosphere.rb', line 11

def pressure
  @pressure
end

#visibilityObject (readonly)

Returns the value of attribute visibility.



11
12
13
# File 'lib/yahoo_weather/atmosphere.rb', line 11

def visibility
  @visibility
end