Class: OfficeQuoteController

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

Instance Method Summary collapse

Constructor Details

#initializeOfficeQuoteController

Returns a new instance of OfficeQuoteController.



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

def initialize
  quotes = Scraper.new
  quotes.get_quote_pages
  start_cli
end

Instance Method Details

#get_dialouge_quoteObject



51
52
53
54
55
56
57
58
# File 'lib/office_quote_controller.rb', line 51

def get_dialouge_quote
  input = ""
  while input != "exit" && input != "n" && input != "N" do
    Quote.get_dialouge
    puts "Would you like to hear another dialouge? (y/n)"
    input = gets.chomp
  end
end

#get_quotes_by_characterObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/office_quote_controller.rb', line 31

def get_quotes_by_character
  input = ""
  while input != "exit" && input != "n" && input != "N" do
    puts "You may choose from these characters: "
    Character.list_all_characters
    puts "Please select from one of the following characters by entering their name: "
    input = gets.chomp
    puts "Would you like to hear 1 or all of their quotes?"
    puts "Enter \"1\" for one quote and anything else to hear all."
    option = gets.chomp
    if option != "1"
      Character.list_all_quotes_for_character(input)
    else
      Character.random_quote_for_character(input)
    end
    puts "Would you like to choose another character? (y/n)"
    input = gets.chomp
  end
end

#get_random_quoteObject



60
61
62
63
64
65
66
67
# File 'lib/office_quote_controller.rb', line 60

def get_random_quote
  input = ""
  while input != "exit" && input != "n" && input != "N" do
    Quote.get_random
    puts "Would you like to hear another quote? (y/n)"
    input = gets.chomp
  end
end

#start_cliObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/office_quote_controller.rb', line 9

def start_cli
  input = ""
  puts "Welcome to The Office Quote Generator"
  while input != "exit" do
    puts "If you'd like to exit, enter \"exit\""
    puts "Please select from the following options: "
    puts "1. Choose a quote from a specific character"
    puts "2. Hear a dialouge quote (between multiple characters)"
    puts "3. Hear a random quote"
    input = gets.chomp
    if input == "1"
      get_quotes_by_character
    elsif input == "2"
      get_dialouge_quote
    elsif input == "3"
      get_random_quote
    elsif input != "exit"
      puts "Please enter 1, 2 or 3"
    end
  end
end