Class: BroadwayNow::CLI

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

Instance Method Summary collapse

Instance Method Details

#add_attributesObject



22
23
24
25
26
27
28
# File 'lib/broadway_now/cli.rb', line 22

def add_attributes 
  BroadwayNow::Show.all.each do |show|
    url = show.url
    extra_info_hash = BroadwayNow::Scraper.additional_scraper(url)
    show.add_info(extra_info_hash)
  end
end

#callObject



4
5
6
7
8
9
10
11
# File 'lib/broadway_now/cli.rb', line 4

def call
  greet
  make_shows
  add_attributes
  list_shows 
  menu
  goodbye
end

#goodbyeObject



67
68
69
70
# File 'lib/broadway_now/cli.rb', line 67

def goodbye
  puts "Goodbye!"
  exit 0
end

#greetObject



13
14
15
# File 'lib/broadway_now/cli.rb', line 13

def greet
  puts "-----Welcome to Broadway Now!-----"
end

#list_showsObject



30
31
32
33
34
35
36
37
# File 'lib/broadway_now/cli.rb', line 30

def list_shows
  puts "-----Shows currently running:-----"
  @shows = BroadwayNow::Show.all
  @shows.each.with_index(1) do |show,i|
    puts "#{i}. #{show.name}"
  end
  puts "----------------------------------"
end

#make_showsObject



17
18
19
20
# File 'lib/broadway_now/cli.rb', line 17

def make_shows
  shows_array = BroadwayNow::Scraper.main_scraper
  BroadwayNow::Show.create_shows(shows_array)
end


39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/broadway_now/cli.rb', line 39

def menu
  input = nil
  while input != "exit"
    puts "Enter show number for more info, 'all' to see all shows, or 'exit' :"
    input = gets.strip.downcase

    if input.to_i > 0 &&  input.to_i < 21 #update if you add more shows
      show = @shows[input.to_i-1] 
      puts "--------------------Details--------------------"
      puts "     Show:             #{show.name}"
      puts "     Theater:         #{show.theater}"
      puts "     Price:            #{show.price}"
      puts "     Website:          #{show.url}"
      puts "     Running Time:     #{show.running_time}"
      puts "\nStory: \n"
      puts "#{show.story}"
      puts "---------------------------------------------"

    elsif input == "all" 
      list_shows
    elsif input == "exit"
      goodbye
    else
      puts "Oops! Incorrect input! Enter show number for more info, 'all' to see all shows, or 'exit' :"  
    end 
  end   
end