Class: CatsToAdopt::Cat

Inherits:
Object
  • Object
show all
Defined in:
lib/cats_to_adopt/cat.rb

Constant Summary collapse

@@all =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCat

INSTANCE METHODS save a cat when it’s created



8
9
10
# File 'lib/cats_to_adopt/cat.rb', line 8

def initialize
  @@all << self
end

Instance Attribute Details

#ageObject

Returns the value of attribute age.



2
3
4
# File 'lib/cats_to_adopt/cat.rb', line 2

def age
  @age
end

#colorObject

Returns the value of attribute color.



2
3
4
# File 'lib/cats_to_adopt/cat.rb', line 2

def color
  @color
end

#genderObject

Returns the value of attribute gender.



2
3
4
# File 'lib/cats_to_adopt/cat.rb', line 2

def gender
  @gender
end

#idObject

Returns the value of attribute id.



2
3
4
# File 'lib/cats_to_adopt/cat.rb', line 2

def id
  @id
end

#locationObject

Returns the value of attribute location.



2
3
4
# File 'lib/cats_to_adopt/cat.rb', line 2

def location
  @location
end

#nameObject

Returns the value of attribute name.



2
3
4
# File 'lib/cats_to_adopt/cat.rb', line 2

def name
  @name
end

#profile_urlObject

Returns the value of attribute profile_url.



2
3
4
# File 'lib/cats_to_adopt/cat.rb', line 2

def profile_url
  @profile_url
end

#sizeObject

Returns the value of attribute size.



2
3
4
# File 'lib/cats_to_adopt/cat.rb', line 2

def size
  @size
end

#weightObject

Returns the value of attribute weight.



2
3
4
# File 'lib/cats_to_adopt/cat.rb', line 2

def weight
  @weight
end

Class Method Details

.allObject

CLASS METHODS



34
35
36
# File 'lib/cats_to_adopt/cat.rb', line 34

def self.all
  @@all
end


38
39
40
41
42
43
44
# File 'lib/cats_to_adopt/cat.rb', line 38

def self.print_cats
  puts "\nCats available now:"

  self.all.each.with_index(1) do |cat, i|
    puts "#{i}. #{cat.name} - #{cat.gender} - #{cat.size}"
  end
end

Instance Method Details

#add_cat_attributes(attributes) ⇒ Object

set additional attributes on a cat



13
14
15
16
17
18
# File 'lib/cats_to_adopt/cat.rb', line 13

def add_cat_attributes(attributes)
  self.color = attributes[:color]
  self.weight = attributes[:weight]
  self.age = attributes[:age]
  self.profile_url = 'https://la.bestfriends.org/get-involved/adopt/pet/' + self.id
end

prints detailed information for a cat



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/cats_to_adopt/cat.rb', line 21

def print_cat_info
  puts "\nCat Name: #{self.name}"
  puts "-- ID: #{self.id}"
  puts "-- Gender: #{self.gender}"
  puts "-- Age: #{self.age}"
  puts "-- Color: #{self.color}"
  puts "-- Size: #{self.size}"
  puts "-- Weight: #{self.weight}"
  puts "-- Location: #{self.location}"
  puts "-- Profile Link: #{self.profile_url}\n"
end