Class: WeatherCli::Weather
- Inherits:
-
Object
- Object
- WeatherCli::Weather
- Defined in:
- lib/weathercli/weather.rb
Instance Attribute Summary collapse
-
#conditions ⇒ Object
readonly
Returns the value of attribute conditions.
-
#forecasts ⇒ Object
readonly
Returns the value of attribute forecasts.
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
-
#initialize(location, *options) ⇒ Weather
constructor
A new instance of Weather.
- #to_s ⇒ Object
Constructor Details
#initialize(location, *options) ⇒ Weather
8 9 10 11 |
# File 'lib/weathercli/weather.rb', line 8 def initialize(location, *) = Hash[.map { |o| [o, true] }] get_weather(location) end |
Instance Attribute Details
#conditions ⇒ Object (readonly)
Returns the value of attribute conditions.
6 7 8 |
# File 'lib/weathercli/weather.rb', line 6 def conditions @conditions end |
#forecasts ⇒ Object (readonly)
Returns the value of attribute forecasts.
6 7 8 |
# File 'lib/weathercli/weather.rb', line 6 def forecasts @forecasts end |
#location ⇒ Object (readonly)
Returns the value of attribute location.
6 7 8 |
# File 'lib/weathercli/weather.rb', line 6 def location @location end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'lib/weathercli/weather.rb', line 6 def end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
6 7 8 |
# File 'lib/weathercli/weather.rb', line 6 def title @title end |
Instance Method Details
#to_s ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/weathercli/weather.rb', line 13 def to_s todays_forecast = forecasts.first tomorrows_forecast = forecasts.last [ title, "#{conditions['temp']} degrees Farenheit; #{conditions['text']}", "Today's forecast: High of #{todays_forecast['high']}, Low of #{todays_forecast['low']}; #{todays_forecast['text']}", "Tomorrow's forecast: High of #{tomorrows_forecast['high']}, Low of #{tomorrows_forecast['low']}; #{tomorrows_forecast['text']}" ].join("\n") end |