Class: YahooWeather::Condition

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(payload) ⇒ Condition

Returns a new instance of Condition.



4
5
6
7
8
9
# File 'lib/yahoo_weather/condition.rb', line 4

def initialize(payload)
  @text = payload['text']
  @code = payload['code'].to_i
  @temp = payload['temp'].to_i
  @date = Time.parse(payload['date'])
end

Instance Attribute Details

#dateObject (readonly)

Returns the value of attribute date.



2
3
4
# File 'lib/yahoo_weather/condition.rb', line 2

def date
  @date
end

#tempObject (readonly)

Returns the value of attribute temp.



2
3
4
# File 'lib/yahoo_weather/condition.rb', line 2

def temp
  @temp
end

#textObject (readonly)

Returns the value of attribute text.



2
3
4
# File 'lib/yahoo_weather/condition.rb', line 2

def text
  @text
end

Instance Method Details

#code(u = 'integer') ⇒ Object



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

def code(u='integer')
  return @code if u == 'integer'
  YahooWeather.code_string(@code)
end