Class: SdEvents::CLI
- Inherits:
-
Object
- Object
- SdEvents::CLI
- Defined in:
- lib/sd_events/cli.rb
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
- #display_events ⇒ Object
- #event_menu ⇒ Object
- #goodbye ⇒ Object
- #list_menu ⇒ Object
- #start ⇒ Object
Class Method Details
.no_events ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/sd_events/cli.rb', line 87 def self.no_events puts "" puts "Uh oh, looks like there are no events for that time..." puts "Please return tomorrow for more events." puts "" puts "To see the menu again, type 'menu' or type 'exit':" input = gets.downcase.strip if input == "menu" self.new. elsif input == "exit" self.new.goodbye else "Not sure what you're asking, here is the menu again:" self.new. end end |
Instance Method Details
#call ⇒ Object
3 4 5 |
# File 'lib/sd_events/cli.rb', line 3 def call start end |
#display_events ⇒ Object
57 58 59 60 61 62 63 64 65 |
# File 'lib/sd_events/cli.rb', line 57 def display_events SdEvents::Events.all.each.with_index(1) do |event, i| puts "#{i}." puts "Event: #{event.name.upcase}" puts "Venue: #{event.venue}" puts "Time: #{event.time}" puts "" end end |
#event_menu ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/sd_events/cli.rb', line 67 def puts "" puts "To see more info about an event, please select the number of the event:" input = gets.downcase.to_i-1 SdEvents::Events.find(input) puts "" puts "Event: #{SdEvents::Events.all[input].name}" puts "City: #{SdEvents::Events.all[input].city}" puts "Category: #{SdEvents::Events.all[input].category}" puts "" puts "To see the menu again, type 'menu' or to exit type 'exit':" SdEvents::Events.all.clear new_input = gets.downcase.strip if new_input == "menu" elsif new_input == "exit" goodbye end end |
#goodbye ⇒ Object
104 105 106 107 |
# File 'lib/sd_events/cli.rb', line 104 def goodbye puts "Thanks for visiting SD Events!" exit end |
#list_menu ⇒ Object
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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/sd_events/cli.rb', line 14 def puts "Hello, the time is now #{Time.now}." puts "Please select which events you would like to see or type 'exit'" puts "" puts "1. Morning Events" puts "2. Afternoon Events" puts "3. Evening Events" puts "4. Late Night Events" puts "" input = gets.strip.downcase if input == "1" SdEvents::Events.create_morning_events display_events elsif input == "2" SdEvents::Events.create_afternoon_events display_events elsif input == "3" SdEvents::Events.create_evening_events display_events elsif input == "4" SdEvents::Events.create_night_events display_events elsif input == "exit" goodbye else puts "Not sure what you're asking, here is the menu again:" end end |
#start ⇒ Object
7 8 9 10 11 12 |
# File 'lib/sd_events/cli.rb', line 7 def start puts "" puts "******* Events Happening Now in San Diego *******" puts "" end |