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
#list ⇒ Object
[View source]
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/UrgentCare/CLI.rb', line 40 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
[View source]
88 89 90 91 92 93 94 |
# File 'lib/UrgentCare/CLI.rb', line 88 def puts " " puts "Retrieving data...." puts "Loading......" puts "............." puts " " end |
#office_details ⇒ Object
[View source]
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/UrgentCare/CLI.rb', line 56 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 "Office 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
[View source]
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/UrgentCare/CLI.rb', line 29 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
[View source]
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 |