Class: WordsAndIdioms::CLI

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

Instance Method Summary collapse

Instance Method Details

#callObject



5
6
7
8
9
# File 'lib/words_and_idioms/cli.rb', line 5

def call
  puts "Welcome to Word Explorer!".red
  greet_user
  goodbye
end

#goodbyeObject



41
42
43
# File 'lib/words_and_idioms/cli.rb', line 41

def goodbye
  puts "I hope you learned something today. See you again soon."
end

#greet_userObject



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/words_and_idioms/cli.rb', line 11

def greet_user
  puts "What would you like to do?"
  puts " "
  puts "1. Retrieve a word's definition from Dictionary.com."
  puts "OR"
  puts "2. See a list of current idiomatic expressions from MacMillan's Open Dictionary."
  puts "OR"
  puts "3. EXIT"
  puts " "
  menu
end


23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/words_and_idioms/cli.rb', line 23

def menu
first_choice = (gets.chomp).to_i
  if first_choice == 1
    DictionaryScraper.new
    greet_user
  elsif first_choice == 2
    IdiomExplorer.idiom_routine
    greet_user
  elsif first_choice != 1 && first_choice != 2 && first_choice != 3
    puts " "
    puts " "
    puts "Sorry, I didn't get that. Please enter '1', '2', or '3'.".red
    puts " "
    greet_user
  elsif first_choice == 3
  end
end