Class: ClimaTempo::Forecast

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(date, opts = {}) ⇒ Forecast

Returns a new instance of Forecast.



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/climatempo/forecast.rb', line 7

def initialize(date, opts={})
  @date = date
  @min  = opts[:min]
  @max  = opts[:max]
  @now  = opts[:now]
  @precipitation = opts[:precipitation]
  @probability   = opts[:probability]
  @conditions    = opts[:conditions]
  @pressure      = opts[:pressure]
  @humidity      = opts[:humidity]
end

Instance Attribute Details

#conditionsObject (readonly)

Returns the value of attribute conditions.



3
4
5
# File 'lib/climatempo/forecast.rb', line 3

def conditions
  @conditions
end

#dateObject (readonly)

Returns the value of attribute date.



3
4
5
# File 'lib/climatempo/forecast.rb', line 3

def date
  @date
end

#humidityObject (readonly)

Returns the value of attribute humidity.



3
4
5
# File 'lib/climatempo/forecast.rb', line 3

def humidity
  @humidity
end

#maxObject (readonly)

Returns the value of attribute max.



3
4
5
# File 'lib/climatempo/forecast.rb', line 3

def max
  @max
end

#minObject (readonly)

Returns the value of attribute min.



3
4
5
# File 'lib/climatempo/forecast.rb', line 3

def min
  @min
end

#nowObject (readonly)

Returns the value of attribute now.



3
4
5
# File 'lib/climatempo/forecast.rb', line 3

def now
  @now
end

#precipitationObject (readonly)

Returns the value of attribute precipitation.



3
4
5
# File 'lib/climatempo/forecast.rb', line 3

def precipitation
  @precipitation
end

#pressureObject (readonly)

Returns the value of attribute pressure.



3
4
5
# File 'lib/climatempo/forecast.rb', line 3

def pressure
  @pressure
end

#probabilityObject (readonly)

Returns the value of attribute probability.



3
4
5
# File 'lib/climatempo/forecast.rb', line 3

def probability
  @probability
end

Instance Method Details

#to_sObject



26
27
28
# File 'lib/climatempo/forecast.rb', line 26

def to_s
  "Temp: (#{max}/#{min}); Humidity: #{humidity}; Precipitation: #{precipitation}; Prob. of rain: #{probability}; Conditions: #{conditions}; Air pressure: #{pressure}"
end

#today?Boolean

Returns:

  • (Boolean)


19
20
21
22
23
24
# File 'lib/climatempo/forecast.rb', line 19

def today?
  now = DateTime.now
  now.year == date.year &&
    now.month == date.month &&
    now.day == date.day
end