Class: Weather::Forecast
- Inherits:
-
Object
- Object
- Weather::Forecast
- Defined in:
- lib/forecast.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#date ⇒ Object
Returns the value of attribute date.
-
#description ⇒ Object
Returns the value of attribute description.
-
#humidity ⇒ Object
Returns the value of attribute humidity.
-
#location ⇒ Object
Returns the value of attribute location.
-
#temp ⇒ Object
Returns the value of attribute temp.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(date:, temp:, humidity:, description:) ⇒ Forecast
constructor
A new instance of Forecast.
- #save ⇒ Object
Constructor Details
#initialize(date:, temp:, humidity:, description:) ⇒ Forecast
Returns a new instance of Forecast.
9 10 11 12 13 14 15 |
# File 'lib/forecast.rb', line 9 def initialize (date:, temp:, humidity:, description:) @date = date @temp = temp @humidity = humidity @description = description save end |
Instance Attribute Details
#date ⇒ Object
Returns the value of attribute date.
7 8 9 |
# File 'lib/forecast.rb', line 7 def date @date end |
#description ⇒ Object
Returns the value of attribute description.
7 8 9 |
# File 'lib/forecast.rb', line 7 def description @description end |
#humidity ⇒ Object
Returns the value of attribute humidity.
7 8 9 |
# File 'lib/forecast.rb', line 7 def humidity @humidity end |
#location ⇒ Object
Returns the value of attribute location.
7 8 9 |
# File 'lib/forecast.rb', line 7 def location @location end |
#temp ⇒ Object
Returns the value of attribute temp.
7 8 9 |
# File 'lib/forecast.rb', line 7 def temp @temp end |
Class Method Details
.all ⇒ Object
44 45 46 |
# File 'lib/forecast.rb', line 44 def self.all @@all end |
.day_display ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/forecast.rb', line 21 def self.day_display forecast = [] 8.times do forecast << @@all.shift end forecast.each do |data| puts Terminal::Table.new( rows: [ [data.date, "Temp: #{data.temp} F Humidity: #{data.humidity} Sky: #{data.description.to_emoji} #{data.description}"] ], style: { border_i: 'X', border_x: '=', width: 130 } ) end end |
.erase ⇒ Object
48 49 50 |
# File 'lib/forecast.rb', line 48 def self.erase @@all.clear end |
Instance Method Details
#save ⇒ Object
17 18 19 |
# File 'lib/forecast.rb', line 17 def save @@all << self end |