Sha256: fc8d5cbaad5fd89a93a8ccb9d49d38a9963f54bb85ffad7cc917c5270f096d20

Contents?: true

Size: 702 Bytes

Versions: 10

Compression:

Stored size: 702 Bytes

Contents

class YahooWeather::Atmosphere
  class Barometer
    STEADY = 'steady'
    RISING = 'rising'
    FALLING = 'falling'

    # lists all possible barometer constants
    ALL = [ STEADY, RISING, FALLING ]
  end

  attr_reader :humidity, :visibility, :pressure, :barometer

  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
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
yahoo_weather-1.1.1 lib/yahoo_weather/atmosphere.rb
yahoo_weather-1.1.0 lib/yahoo_weather/atmosphere.rb
yahoo_weather-1.0.7 lib/yahoo_weather/atmosphere.rb
yahoo_weather-1.0.6 lib/yahoo_weather/atmosphere.rb
yahoo_weather-1.0.5 lib/yahoo_weather/atmosphere.rb
yahoo_weather-1.0.4 lib/yahoo_weather/atmosphere.rb
yahoo_weather-1.0.3 lib/yahoo_weather/atmosphere.rb
yahoo_weather-1.0.2 lib/yahoo_weather/atmosphere.rb
yahoo_weather-1.0.1 lib/yahoo_weather/atmosphere.rb
yahoo_weather-1.0.0 lib/yahoo_weather/atmosphere.rb