Class: Umbrella::CLI
- Inherits:
-
Object
- Object
- Umbrella::CLI
- Defined in:
- lib/Umbrella/CLI.rb
Instance Attribute Summary collapse
-
#rain ⇒ Object
Returns the value of attribute rain.
Instance Method Summary collapse
- #call ⇒ Object
- #choose ⇒ Object
- #choose_location ⇒ Object
- #further_prompt ⇒ Object
- #gonna_rain ⇒ Object
Instance Attribute Details
#rain ⇒ Object
Returns the value of attribute rain.
2 3 4 |
# File 'lib/Umbrella/CLI.rb', line 2 def rain @rain end |
Instance Method Details
#call ⇒ Object
4 5 6 7 8 9 |
# File 'lib/Umbrella/CLI.rb', line 4 def call choose_location gonna_rain further_prompt choose end |
#choose ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/Umbrella/CLI.rb', line 63 def choose choice = nil while choice != "exit" puts "Choose a number, type 'list' to see options again, type 'city' to change location, or 'exit' to leave." choice = gets.chomp case choice when "1" puts "" puts "Weather Report: Temperature- #{@rain.temperature} Condition- #{@rain.weather_condition} Wind- #{@rain.wind} Sunrise- #{@rain.sunrise}, Sunset - #{@rain.sunset} " puts "" when "2" puts "" puts "#{@rain.temperature}" puts "" when "3" puts "" puts "#{@rain.weather_condition}" puts "" when "4" puts "" puts "#{@rain.wind}" puts "" when "5" puts "" puts "Sunrise- #{@rain.sunrise}, Sunset - #{@rain.sunset}" puts "" when "exit" puts "" puts "Stay dry!" puts "" exit when "list" puts " 1) Weather Report 2) Temperature 3) Weather Condition 4) Wind Speed 5) Sunrise/Sunset " when "city" call else puts "Did not understand that commmand." end end end |
#choose_location ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/Umbrella/CLI.rb', line 11 def choose_location puts "Do you need an Umbrella today in:(pick a number)" ["Chicago", "New York", "Los Angeles"].each.with_index(1){|a, i| puts "#{i}. #{a}"} input = gets.chomp.downcase case input when "1" @rain = Umbrella::Weather.weather_setter("Chicago+IL+USIL0225:1:US") when "2" @rain = Umbrella::Weather.weather_setter("USNY0996:1:US") when "3" @rain = Umbrella::Weather.weather_setter("USCA0638:1:US") when "exit" puts "Stay dry!" exit else puts "Please try a number 1-3." choose_location end end |
#further_prompt ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/Umbrella/CLI.rb', line 46 def further_prompt puts "Would you like to know more about today's weather(y/n):" input = gets.chomp.downcase if input == "y" puts " 1) Weather Report 2) Temperature 3) Weather Condition 4) Wind Speed 5) Sunrise/Sunset " else puts "Stay dry!" exit end end |
#gonna_rain ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/Umbrella/CLI.rb', line 33 def gonna_rain if @rain.rain_perc != "0%" puts "" puts "Looks like rain is in the forecast, better grab an umbrella! The chance of rain is #{@rain.rain_perc}." puts "" else puts "" puts "No rain today! Leave that umbrella at home." puts "" end end |