Class: ReligioCLI::CLI
- Inherits:
-
Object
- Object
- ReligioCLI::CLI
- Defined in:
- lib/religio_cli/cli.rb
Instance Method Summary collapse
- #call ⇒ Object
- #display_religion(integer) ⇒ Object
- #goodbye ⇒ Object
- #list_religions ⇒ Object
- #menu ⇒ Object
Instance Method Details
#call ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/religio_cli/cli.rb', line 3 def call ReligioCLI::Scraper.initiate_scraper puts "Hello there! Welcome to Religio. I offer information on the top 50 Major Religious traditions. To see the list presented in alphabetical order, enter 'list'. To exit, enter 'exit'." input = nil input = gets.strip.downcase if input == "list" list_religions elsif input == "exit" goodbye exit else puts "I'm not sure what you'd like. Please see the below the list:" list_religions end end |
#display_religion(integer) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/religio_cli/cli.rb', line 27 def display_religion(integer) user_selection = ReligioCLI::Trads.all[integer-1] puts " " puts user_selection.name.upcase puts " " puts user_selection.quick_facts puts " " puts "#{user_selection.description}" puts " " puts "To learn more, visit:" puts user_selection.url end |
#goodbye ⇒ Object
74 75 76 |
# File 'lib/religio_cli/cli.rb', line 74 def goodbye puts "Thanks for exploring! I hope you learned something cool today. Feel free to stop by anytime :)" end |
#list_religions ⇒ Object
21 22 23 24 25 |
# File 'lib/religio_cli/cli.rb', line 21 def list_religions ReligioCLI::Trads.all.each.with_index(1) do |religion, index| puts "#{index}. #{religion.name}" end end |
#menu ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/religio_cli/cli.rb', line 40 def puts "For details on a particular tradition, type the number associated." puts "To exit at any time, enter 'exit'." puts "Which religious tradition would you like to learn more about?" choice = nil choice = gets.strip if choice.to_i > 0 && choice.to_i <= ReligioCLI::Trads.all.length display_religion(choice.to_i) puts "Would you like to learn more about another religion?" puts "Enter Y or N" input = gets.strip.downcase if input == "y" list_religions elsif input == "n" goodbye exit elsif input == "exit" goodbye exit else puts "I'm not sure what you'd like. Please see the below the list:" list_religions end elsif choice == "exit".downcase goodbye else puts "I'm not sure what you'd like. Please enter a number between 1 and 50. If you want to leave, enter 'exit'." list_religions end end |