Class: CommandLineInterface

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

Instance Method Summary collapse

Instance Method Details

#invalidObject



59
60
61
# File 'lib/cli.rb', line 59

def invalid
  puts "\nInvalid command please enter a valid command."
end

#list_menuObject



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

def list_menu
  puts "If you would like get more information about a specific show enter their index number, \ntype 'list' to show the list of today's episode, or 'exit'"
  input = gets.strip.downcase
  
  if input.to_i.between?(1, Show.all.count)
    show_info(Show.all[input.to_i-1])
    show_menu
  elsif input == "list"
    list_show
    list_menu
  elsif input == "exit"
  else
    invalid
    list_menu
  end
end

#list_showObject



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

def list_show
  puts "\nToday's new episodes are:"
  Show.all.uniq.each_with_index do |show, index|
    puts "#{index+1}. #{show.name}"
  end
  puts ""
end

#runObject



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

def run
  puts "\nLoading today's new TV episodes. \n(This might take a couple of minutes)"
  Scrapper.list_scrapper
  list_show
  list_menu
end

#show_info(show) ⇒ Object



34
35
36
37
38
39
40
41
42
43
# File 'lib/cli.rb', line 34

def show_info(show)
  puts "\n#{show.name}"
  puts "\nSummary: #{show.summary}"
  puts "\nGenre: #{show.genre.join(", ")}"
  puts "Channel: #{show.channel}"
  puts "Showtime: #{show.showtime}"
  puts "Current Season: #{show.season}"
  puts "New Episode: #{show.episode}. #{show.episode_name}"
  puts ""
end

#show_menuObject



45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/cli.rb', line 45

def show_menu
  puts "Type 'list' to show the list of today's episode, or 'exit'"
  input = gets.strip.downcase

  if input == "list"
    list_show
    list_menu
  elsif input == "exit"
  else
    invalid
    show_menu
  end
end