Class: WordsAndIdioms::CLI
- Inherits:
-
Object
- Object
- WordsAndIdioms::CLI
- Defined in:
- lib/words_and_idioms/cli.rb
Instance Method Summary collapse
Instance Method Details
#call ⇒ Object
3 4 5 6 7 |
# File 'lib/words_and_idioms/cli.rb', line 3 def call puts "Welcome to Word Explorer!".red greet_user goodbye end |
#goodbye ⇒ Object
50 51 52 |
# File 'lib/words_and_idioms/cli.rb', line 50 def goodbye puts "I hope you learned something today. See you again soon." end |
#greet_user ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/words_and_idioms/cli.rb', line 9 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 " " end |
#menu ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/words_and_idioms/cli.rb', line 29 def first_choice = (gets.chomp).to_i if first_choice == 1 DictionaryScraper.new greet_user elsif first_choice == 2 IdiomScraper.constructor print_idiom_list 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 |
#print_idiom_list ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/words_and_idioms/cli.rb', line 21 def print_idiom_list puts "Below is a list of newly created idioms from MacMillan's Open Dictionary Project" Idiom.all.each.with_index(1) do |idiom, i| puts "#{i}. #{idiom.name}" end IdiomExplorer.show_idiom end |