Class: Yweather::Condition

Inherits:
Object
  • Object
show all
Includes:
Utils
Defined in:
lib/yweather/condition.rb

Constant Summary collapse

CODES =
{
  0   => "tornado",
  1   => "tropical storm",
  2   => "hurricane",
  3   => "severe thunderstorms",
  4   => "thunderstorms",
  5   => "mixed rain and snow",
  6   => "mixed rain and sleet",
  7   => "mixed snow and sleet",
  8   => "freezing drizzle",
  9   => "drizzle",
  10  => "freezing rain",
  11  => "showers",
  12  => "showers",
  13  => "snow flurries",
  14  => "light snow showers",
  15  => "blowing snow",
  16  => "snow",
  17  => "hail",
  18  => "sleet",
  19  => "dust",
  20  => "foggy",
  21  => "haze",
  22  => "smoky",
  23  => "blustery",
  24  => "windy",
  25  => "cold",
  26  => "cloudy",
  27  => "mostly cloudy (night)",
  28  => "mostly cloudy (day)",
  29  => "partly cloudy (night)",
  30  => "partly cloudy (day)",
  31  => "clear (night)",
  32  => "sunny",
  33  => "fair (night)",
  34  => "fair (day)",
  35  => "mixed rain and hail",
  36  => "hot",
  37  => "isolated thunderstorms",
  38  => "scattered thunderstorms",
  39  => "scattered thunderstorms",
  40  => "scattered showers",
  41  => "heavy snow",
  42  => "scattered snow showers",
  43  => "heavy snow",
  44  => "partly cloudy",
  45  => "thundershowers",
  46  => "snow showers",
  47  => "isolated thundershowers",
  3200 => "not available"
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utils

#parse_time

Constructor Details

#initialize(data) ⇒ Condition

Returns a new instance of Condition.



63
64
65
66
67
68
# File 'lib/yweather/condition.rb', line 63

def initialize(data)
  @code = data[:code].to_i
  @date = parse_time(data[:date])
  @temp = data[:temp].to_i
  @text = data[:text]
end

Instance Attribute Details

#codeObject (readonly)

the Yahoo! Weather condition code, as detailed at developer.yahoo.com/weather.



58
59
60
# File 'lib/yweather/condition.rb', line 58

def code
  @code
end

#dateObject (readonly)

Returns the value of attribute date.



59
60
61
# File 'lib/yweather/condition.rb', line 59

def date
  @date
end

#tempObject (readonly)

Returns the value of attribute temp.



60
61
62
# File 'lib/yweather/condition.rb', line 60

def temp
  @temp
end

#textObject (readonly)

Returns the value of attribute text.



61
62
63
# File 'lib/yweather/condition.rb', line 61

def text
  @text
end