Class: Weather::Atmosphere

Inherits:
Object
  • Object
show all
Defined in:
lib/weather-api/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.



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

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

#humidityObject (readonly)

air humidity



13
14
15
# File 'lib/weather-api/atmosphere.rb', line 13

def humidity
  @humidity
end

#pressureObject (readonly)

air pressure level



19
20
21
# File 'lib/weather-api/atmosphere.rb', line 19

def pressure
  @pressure
end

#visibilityObject (readonly)

visibility of the surroundings



16
17
18
# File 'lib/weather-api/atmosphere.rb', line 16

def visibility
  @visibility
end