Class: MovieGem::CLI

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

Instance Method Summary collapse

Instance Method Details

#display_synopsisObject



39
40
41
42
43
44
45
# File 'lib/movie_gem/CLI.rb', line 39

def display_synopsis
    @object = Movie.all
    @object.each.with_index(1) do |movie, i|
        puts "#{i}. #{movie.synopsis}"
    end

end


24
25
26
27
28
29
# File 'lib/movie_gem/CLI.rb', line 24

def menu
    puts "Please select from the following options"
    puts "1, Display a list of movies"
    puts "2, Display all synopses"
    puts "To see this list at anytime type 'menu'"
end

#movie_listObject



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

def movie_list
  @object = Movie.all
  @object.each.with_index(1) do |movie, i|
     puts "#{i}. #{movie.title}"
  end
  prompt_for_movie_choice

end

#prompt_for_movie_choiceObject



46
47
48
49
50
51
52
53
54
55
# File 'lib/movie_gem/CLI.rb', line 46

def prompt_for_movie_choice
    puts "Which movie would you like more info about?"
    puts "Pick a number"
    @input = gets.chomp
    index = @input.to_i-1
    if index >= 0
        puts Movie.all[@input.to_i-1].synopsis
    end
    menu  
end

#startObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/movie_gem/CLI.rb', line 5

def start
    puts "Welcome to MovieGem"
    Movie.load
    menu
    input = nil
    while @input != "exit"
        @input = gets.chomp
        if @input == "menu"
            menu
        elsif @input == "1"
            movie_list
            puts "display's a list of movies"
        elsif @input == "2"
            display_synopsis
            puts "display_synopsis"
        end
    end
    puts "Thanks for checking out our MovieGem"
end