Class: CatAdoption::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/cat_adoption/cli.rb

Instance Method Summary collapse

Instance Method Details

#callObject



3
4
5
6
7
8
9
# File 'lib/cat_adoption/cli.rb', line 3

def call
  puts "Welcome to Austin Humane Society, located at 124 W. Anderson Lane, Austin, Texas!"
  CatAdoption::Scraper.scrape_main_page
  show_list
  selection
  leave
end

#leaveObject



52
53
54
55
# File 'lib/cat_adoption/cli.rb', line 52

def leave
  puts " "
  puts "Thank you for visiting Austin Humane Society! Come back soon!"
end

#selectionObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/cat_adoption/cli.rb', line 20

def selection
    loop do

    puts " "
    puts "Please select the number of the cat you would like to learn about or type in \"cats\" to see the list again or type \"exit\" to leave:"
    input = gets.strip.downcase

    if input.to_i > 0 && input.to_i <= @cats.count
      cat = @cats[input.to_i - 1]
      CatAdoption::Scraper.scrape_bio_page(cat)
      puts " "
      puts "#{cat.number_label} #{cat.number}"
      puts "#{cat.breed_label} #{cat.breed}"
      puts "#{cat.sex_label} #{cat.sex}"
      puts "#{cat.dob_label} #{cat.dob}"
      puts "#{cat.age_label} #{cat.age}"
      puts "#{cat.weight_label} #{cat.weight}"
      puts "#{cat.color_label} #{cat.color}"
      puts "#{cat.location_label} #{cat.location}"
      puts "#{cat.fee_label} #{cat.fee}"
      puts "#{cat.description}"
    elsif input == "exit"
      return
    elsif input == "cats"
      show_list
    else
      puts " "
      puts "Invalid choice. Please type in either \"cats\" or \"exit.\""
    end
  end
end

#show_listObject



11
12
13
14
15
16
17
18
# File 'lib/cat_adoption/cli.rb', line 11

def show_list
  puts " "
  puts "Here is a list of all the cute cats available for adoption:"
  @cats = CatAdoption::Cat.all
  @cats.each.with_index(1) do |cat, i|
    puts "#{i}. #{cat.name}"
  end
end