Class: YahooWeather::Forecast

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(payload) ⇒ Forecast

Returns a new instance of Forecast.



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

def initialize(payload)
  @date = Date.parse(payload['date'])
  @text = payload['text']
  @day  = payload['day']
  @code = payload['code'].to_i
  @high = payload['high'].to_i
  @low  = payload['low'].to_i
end

Instance Attribute Details

#dateObject (readonly)

Returns the value of attribute date.



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

def date
  @date
end

#dayObject (readonly)

Returns the value of attribute day.



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

def day
  @day
end

#highObject (readonly)

Returns the value of attribute high.



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

def high
  @high
end

#lowObject (readonly)

Returns the value of attribute low.



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

def low
  @low
end

#textObject (readonly)

Returns the value of attribute text.



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

def text
  @text
end

Instance Method Details

#code(u = 'integer') ⇒ Object



13
14
15
16
# File 'lib/yahoo_weather/forecast.rb', line 13

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