Class: TopTv::CLI

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

Instance Method Summary collapse

Instance Method Details

#callObject



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

def call
  main_menu
  list_shows
  goodbye
end

#goodbyeObject



66
67
68
69
# File 'lib/top_tv/cli.rb', line 66

def goodbye
  puts ""
  puts "Goodbye!"
end

#list_show_info(show) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
# File 'lib/top_tv/cli.rb', line 54

def list_show_info(show)
  puts ""
  puts "~~~ #{show.name} ~~~"
  puts ""
  puts "#{show.description}"
  puts ""
  puts "Genre: #{show.genre}"
  puts "Network: #{show.network}"
  puts "Premiere Date: #{show.premiere_date}"
  puts ""
end

#list_showsObject



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
# File 'lib/top_tv/cli.rb', line 20

def list_shows
  puts ""
  puts "Please enter the corresponding number or enter exit to quit:"
  input = gets.strip.downcase

  if input != "exit"
    puts ""
    heading = @headings[input.to_i-1]
    puts "~~~ #{heading.name} ~~~"
    puts ""
    the_shows = heading.shows
    the_shows.each.with_index(1) do |show, i|
      puts "#{i}. #{show}"
    end
    TopTv::Scraper.make_shows
    puts ""
    puts "What show would you like more info on?"
    input = gets.strip.to_i

    chosen_show = the_shows[input.to_i-1]
    show = TopTv::Show.find_show_by_name(chosen_show)
    list_show_info(show)

    puts "Is there another show that you'd like to learn more about? (y/n)"
    input = gets.strip.downcase

    if input == "y"
      @headings.clear
      main_menu
      list_shows
    end
  end
end


9
10
11
12
13
14
15
16
17
18
# File 'lib/top_tv/cli.rb', line 9

def main_menu
  puts ""
  puts "~~~ Welcome to Top TV Shows! ~~~"
  puts ""
  TopTv::Scraper.make_headings
  @headings = TopTv::Heading.all
  @headings.each.with_index(1) do |heading, i|
    puts "#{i}. #{heading.name}"
  end
end