Class: SdEvents::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/sd_events/cli.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.no_eventsObject



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.list_menu
  elsif input == "exit"
    self.new.goodbye
  else
    "Not sure what you're asking, here is the menu again:"
    self.new.list_menu
  end
end

Instance Method Details

#callObject



3
4
5
# File 'lib/sd_events/cli.rb', line 3

def call
  start
end

#display_eventsObject



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_menuObject



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 event_menu
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"
        list_menu
      elsif new_input == "exit"
        goodbye
      end
end

#goodbyeObject



104
105
106
107
# File 'lib/sd_events/cli.rb', line 104

def goodbye
  puts "Thanks for visiting SD Events!"
  exit
end

#list_menuObject



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 list_menu

  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
    event_menu

  elsif input == "2"
    SdEvents::Events.create_afternoon_events
    display_events
    event_menu

  elsif input == "3"
    SdEvents::Events.create_evening_events
    display_events
    event_menu

  elsif input == "4"
    SdEvents::Events.create_night_events
    display_events
    event_menu

  elsif input == "exit"
    goodbye

  else
      puts "Not sure what you're asking, here is the menu again:"
      list_menu
  end

end

#startObject



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 ""
  list_menu
end