Class: Urgentcare::CLI
- Inherits:
-
Object
- Object
- Urgentcare::CLI
- Defined in:
- lib/UrgentCare/CLI.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(scraper: Urgentcare::Scraper.new, offices: Urgentcare::Office.all) ⇒ CLI
constructor
remove strict dependency on other classes.
- #list ⇒ Object
- #loading_message ⇒ Object
- #office_details ⇒ Object
- #office_list ⇒ Object
- #welcome ⇒ Object
Constructor Details
#initialize(scraper: Urgentcare::Scraper.new, offices: Urgentcare::Office.all) ⇒ CLI
remove strict dependency on other classes
8 9 10 11 |
# File 'lib/UrgentCare/CLI.rb', line 8 def initialize(scraper: Urgentcare::Scraper.new, offices: Urgentcare::Office.all) @scraper = scraper @offices = offices end |
Instance Method Details
#call ⇒ Object
13 14 15 |
# File 'lib/UrgentCare/CLI.rb', line 13 def call welcome end |
#list ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/UrgentCare/CLI.rb', line 48 def list puts " " location = $stdin.gets.chomp if location == "Exit" ||location == "exit" puts "Thank you and Goodbye!" elsif location != "Exit" || location != "exit" location = location.to_i $index = location - 1 @scraper.get_clinic_site office_details else puts "Invalid response" end end |
#loading_message ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/UrgentCare/CLI.rb', line 29 def puts " " puts "Retrieving data...." puts "Loading......" puts "............." puts " " end |
#office_details ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/UrgentCare/CLI.rb', line 64 def office_details if $index != "Exit" || $index != "exit" puts " " puts " " puts " " puts "---" puts "Office Name: #{@offices[$index].name}" puts "Office Number: #{@offices[$index].phone_number}" puts "Appointment URL: #{@offices[$index].url}" puts "Office Next Available Appointment: #{@offices[$index].next_available}" puts "---" puts " " puts " " puts " " else puts "No results found. Please try again." end puts " " puts " " puts " " puts "Would you like to select another office from the list?" puts " " @offices.each_with_index do |office, i| puts "#{i + 1}. #{office.name}" end puts " " puts "If not, please type exit." puts " " list end |
#office_list ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/UrgentCare/CLI.rb', line 37 def office_list @scraper.get_office_list puts "Please choose a number from the following list for details on an Urgent Care location." puts " " @offices.each_with_index do |office, i| puts "#{i + 1}. #{office.name}" end list end |
#welcome ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/UrgentCare/CLI.rb', line 17 def welcome #puts displays with a new line puts " " puts " " puts "Welcome to the Urgent Care CLI" puts " " puts " " puts " " office_list end |