Module: Inputable::InstanceMethods
- Included in:
- PHLCovidTesting::CLI, PHLCovidTesting::TestingLocation
- Defined in:
- lib/concerns/Inputable.rb
Instance Method Summary collapse
- #get_input_all(all_sites) ⇒ Object
- #get_input_main ⇒ Object
- #get_input_main_options ⇒ Object
- #get_input_sub(result_array) ⇒ Object
Instance Method Details
#get_input_all(all_sites) ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/concerns/Inputable.rb', line 63 def get_input_all(all_sites) input = nil while input == nil input = gets.strip.downcase if input == "exit" puts "\nGoodbye!\n".colorize(:green) elsif input == "main" elsif !all_sites.include?(all_sites[input.to_i - 1]) puts "\nNo match found. Please try again.\n".colorize(:red) get_input_all(all_sites) elsif input == "all" display_all else display_detail(all_sites[input.to_i - 1]) puts "\nEnter another number to see location details, 'all' to see the full list again, 'main' to return to the main menu,\nor 'exit' to end the program.\n".colorize(:yellow) get_input_sub(all_sites) end end end |
#get_input_main ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/concerns/Inputable.rb', line 26 def get_input_main input = nil while input == nil input = gets.strip.downcase if input == "exit" puts "\nGoodbye!\n".colorize(:green) elsif input == "all" display_all elsif input.include?("walk") || input.include?("drive") search_by_access(input) else search_by_name_or_zipcode(input) end end end |
#get_input_main_options ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/concerns/Inputable.rb', line 3 def input = nil puts "\nYou can search for a COVID-19 testing location in Philadelphia by:".colorize(:yellow) puts " - Searching by name".colorize(:yellow) puts " - Entering a zip code".colorize(:yellow) puts " - Entering 'walk' to see all walk-up locations".colorize(:yellow) puts " - Entering 'drive' to see all drive-thru locations".colorize(:yellow) puts " - Entering 'all' to see all testing locations".colorize(:yellow) puts " - Or 'exit' to end the program.\n".colorize(:yellow) while input == nil input = gets.strip.downcase if input == "exit" puts "\nGoodbye!\n".colorize(:green) elsif input == "all" display_all elsif input == "walk" || input == "drive" search_by_access(input) else search_by_name_or_zipcode(input) end end end |
#get_input_sub(result_array) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/concerns/Inputable.rb', line 42 def get_input_sub(result_array) input = nil while input == nil input = gets.strip.downcase if input == "exit" puts "\nGoodbye!\n".colorize(:green) elsif input == "main" elsif input == "all" display_all elsif !result_array.include?(result_array[input.to_i - 1]) puts "\nNo match found. Please try again.\n".colorize(:red) get_input_sub(result_array) else display_detail(result_array[input.to_i - 1]) puts "\nEnter another number to see location details, 'all' to see the full list, 'main' to return to the main menu,\nor 'exit' to end the program.\n".colorize(:yellow) get_input_sub(result_array) end end end |