Class: ClimaTempo::Forecast
- Inherits:
-
Object
- Object
- ClimaTempo::Forecast
- Defined in:
- lib/climatempo/forecast.rb
Instance Attribute Summary collapse
-
#conditions ⇒ Object
readonly
Returns the value of attribute conditions.
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#humidity ⇒ Object
readonly
Returns the value of attribute humidity.
-
#max ⇒ Object
readonly
Returns the value of attribute max.
-
#min ⇒ Object
readonly
Returns the value of attribute min.
-
#now ⇒ Object
readonly
Returns the value of attribute now.
-
#precipitation ⇒ Object
readonly
Returns the value of attribute precipitation.
-
#pressure ⇒ Object
readonly
Returns the value of attribute pressure.
-
#probability ⇒ Object
readonly
Returns the value of attribute probability.
Instance Method Summary collapse
-
#initialize(date, opts = {}) ⇒ Forecast
constructor
A new instance of Forecast.
- #to_s ⇒ Object
- #today? ⇒ Boolean
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
#conditions ⇒ Object (readonly)
Returns the value of attribute conditions.
3 4 5 |
# File 'lib/climatempo/forecast.rb', line 3 def conditions @conditions end |
#date ⇒ Object (readonly)
Returns the value of attribute date.
3 4 5 |
# File 'lib/climatempo/forecast.rb', line 3 def date @date end |
#humidity ⇒ Object (readonly)
Returns the value of attribute humidity.
3 4 5 |
# File 'lib/climatempo/forecast.rb', line 3 def humidity @humidity end |
#max ⇒ Object (readonly)
Returns the value of attribute max.
3 4 5 |
# File 'lib/climatempo/forecast.rb', line 3 def max @max end |
#min ⇒ Object (readonly)
Returns the value of attribute min.
3 4 5 |
# File 'lib/climatempo/forecast.rb', line 3 def min @min end |
#now ⇒ Object (readonly)
Returns the value of attribute now.
3 4 5 |
# File 'lib/climatempo/forecast.rb', line 3 def now @now end |
#precipitation ⇒ Object (readonly)
Returns the value of attribute precipitation.
3 4 5 |
# File 'lib/climatempo/forecast.rb', line 3 def precipitation @precipitation end |
#pressure ⇒ Object (readonly)
Returns the value of attribute pressure.
3 4 5 |
# File 'lib/climatempo/forecast.rb', line 3 def pressure @pressure end |
#probability ⇒ Object (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_s ⇒ Object
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
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 |