Class: TheatreCliGem::CLI

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

Instance Method Summary collapse

Instance Method Details

#callObject



3
4
5
6
7
# File 'lib/theatre_cli_gem/cli.rb', line 3

def call
  list_shows
  menu
  goodbye
end

#goodbyeObject



32
33
34
# File 'lib/theatre_cli_gem/cli.rb', line 32

def goodbye
  puts "We hope you found the information you were seeking. Enjoy!"
end

#list_showsObject



9
10
11
12
13
14
# File 'lib/theatre_cli_gem/cli.rb', line 9

def list_shows
  puts "Broadway Shows Currently Playing:"
  TheatreCliGem::Show.scrape_shows.each.with_index(1) do |show, i|
    puts "#{i}. #{show.name}"
  end
end


16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/theatre_cli_gem/cli.rb', line 16

def menu
  input = nil
  while input != "exit"
    puts "\nEnter the number of the show you're interested in or type 'list' for the list of current shows or type 'exit' to leave:"
    input = gets.strip.downcase
    if input.to_i > 0 && input.to_i < TheatreCliGem::Show.all.length+1
      selected_show = TheatreCliGem::Show.find(input.to_i)
      puts "\nShow Name:\n#{selected_show.name}\n\nTheater:\n#{selected_show.theater}\n\nSummary:\n#{selected_show.summary}"
    elsif input == "list"
      list_shows
    else
      puts "Invalid entry.\nType 'list' to list Broadway shows currently playing or type 'exit' to leave:" if input != "exit"
    end
  end
end