Class: CatsToAdopt::CLI
- Inherits:
-
Object
- Object
- CatsToAdopt::CLI
- Defined in:
- lib/cats_to_adopt/CLI.rb
Constant Summary collapse
- BASE_PATH =
"https://la.bestfriends.org/get-involved/adopt/"
Instance Method Summary collapse
- #call ⇒ Object
- #goodbye ⇒ Object
- #intro_message ⇒ Object
- #list_cats ⇒ Object
- #make_cats ⇒ Object
- #menu ⇒ Object
Instance Method Details
#call ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/cats_to_adopt/CLI.rb', line 5 def call make_cats list_cats goodbye end |
#goodbye ⇒ Object
52 53 54 |
# File 'lib/cats_to_adopt/CLI.rb', line 52 def goodbye puts "\nGoodbye!" end |
#intro_message ⇒ Object
13 14 15 16 17 18 |
# File 'lib/cats_to_adopt/CLI.rb', line 13 def puts "\n-----------------------------" puts "| Welcome to Cats to Adopt! |" puts "-----------------------------\n\n" puts "Retrieving cat info..." end |
#list_cats ⇒ Object
24 25 26 |
# File 'lib/cats_to_adopt/CLI.rb', line 24 def list_cats CatsToAdopt::Cat.print_cats end |
#make_cats ⇒ Object
20 21 22 |
# File 'lib/cats_to_adopt/CLI.rb', line 20 def make_cats CatsToAdopt::Scraper.scrape_main_page(BASE_PATH + 'pets?field_animal_species_tid_selective=958') end |
#menu ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/cats_to_adopt/CLI.rb', line 28 def input = "" while input != "exit" puts "\nEnter the number of the cat you would like more info on." puts "Type list to list all cats or exit to exit the program." input = gets.strip cats = CatsToAdopt::Cat.all if input.to_i > 0 && input.to_i < cats.size + 1 cat_in_question = cats[input.to_i - 1] attributes = CatsToAdopt::Scraper.scrape_profile_page(BASE_PATH + 'pet/' + cat_in_question.id) cat_in_question.add_cat_attributes(attributes) cat_in_question.print_cat_info elsif input == "list" list_cats elsif input == "exit" puts "\nClosing program ..." else puts "Please enter the number of a cat, list, or exit." end end def goodbye puts "\nGoodbye!" end end |