Class: WeatherByDcq::View
- Inherits:
-
Object
- Object
- WeatherByDcq::View
- Defined in:
- lib/weather_by_dcq/view.rb
Defined Under Namespace
Classes: WeatherError
Instance Attribute Summary collapse
-
#forecast ⇒ Object
Returns the value of attribute forecast.
-
#location ⇒ Object
Returns the value of attribute location.
Instance Method Summary collapse
Instance Attribute Details
#forecast ⇒ Object
Returns the value of attribute forecast.
7 8 9 |
# File 'lib/weather_by_dcq/view.rb', line 7 def forecast @forecast end |
#location ⇒ Object
Returns the value of attribute location.
7 8 9 |
# File 'lib/weather_by_dcq/view.rb', line 7 def location @location end |
Instance Method Details
#menu ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/weather_by_dcq/view.rb', line 9 def puts '' puts 'Please enter a city to retrieve a forecast (Format: City State):' input_location = gets.strip location = input_location.gsub(/[\W\d]/, '').downcase puts "You entered: #{location}".colorize(:blue) + ' Is this correct (Y/N)?' input_confirm = gets.strip.downcase if input_confirm == 'n' puts 'I am sorry, let us try again.' elsif input_confirm == 'y' system('cls') || system('clear') puts '' puts "Current Conditions for #{location}:".colorize(:blue) puts '=====================================' WeatherByDcq::Forecast.display_curr_table(location) # Extended forecast List puts 'Extended forecast:'.colorize(:blue) puts '--------------------' WeatherByDcq::Forecast.display_forecast_list puts '' else begin raise WeatherError rescue WeatherError => e puts e. end end end |
#options_menu ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/weather_by_dcq/view.rb', line 43 def puts '' puts 'Would you like additional details about any of the days listed?'.colorize(:blue) puts 'Please enter the corresponding number for your request, or any letter to EXIT: '.colorize(:blue) detail_input = gets.strip.to_i if detail_input.positive? && detail_input < 9 system('cls') || system('clear') WeatherByDcq::Forecast.display_details(detail_input) elsif detail_input.negative? || detail_input > 8 begin raise WeatherError rescue WeatherError => e puts e. end else exit end end |