Class: CatsToAdopt::Cat
- Inherits:
-
Object
- Object
- CatsToAdopt::Cat
- Defined in:
- lib/cats_to_adopt/cat.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#age ⇒ Object
Returns the value of attribute age.
-
#color ⇒ Object
Returns the value of attribute color.
-
#gender ⇒ Object
Returns the value of attribute gender.
-
#id ⇒ Object
Returns the value of attribute id.
-
#location ⇒ Object
Returns the value of attribute location.
-
#name ⇒ Object
Returns the value of attribute name.
-
#profile_url ⇒ Object
Returns the value of attribute profile_url.
-
#size ⇒ Object
Returns the value of attribute size.
-
#weight ⇒ Object
Returns the value of attribute weight.
Class Method Summary collapse
-
.all ⇒ Object
CLASS METHODS.
- .print_cats ⇒ Object
Instance Method Summary collapse
-
#add_cat_attributes(attributes) ⇒ Object
set additional attributes on a cat.
-
#initialize ⇒ Cat
constructor
INSTANCE METHODS save a cat when it’s created.
-
#print_cat_info ⇒ Object
prints detailed information for a cat.
Constructor Details
#initialize ⇒ Cat
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
#age ⇒ Object
Returns the value of attribute age.
2 3 4 |
# File 'lib/cats_to_adopt/cat.rb', line 2 def age @age end |
#color ⇒ Object
Returns the value of attribute color.
2 3 4 |
# File 'lib/cats_to_adopt/cat.rb', line 2 def color @color end |
#gender ⇒ Object
Returns the value of attribute gender.
2 3 4 |
# File 'lib/cats_to_adopt/cat.rb', line 2 def gender @gender end |
#id ⇒ Object
Returns the value of attribute id.
2 3 4 |
# File 'lib/cats_to_adopt/cat.rb', line 2 def id @id end |
#location ⇒ Object
Returns the value of attribute location.
2 3 4 |
# File 'lib/cats_to_adopt/cat.rb', line 2 def location @location end |
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/cats_to_adopt/cat.rb', line 2 def name @name end |
#profile_url ⇒ Object
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 |
#size ⇒ Object
Returns the value of attribute size.
2 3 4 |
# File 'lib/cats_to_adopt/cat.rb', line 2 def size @size end |
#weight ⇒ Object
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
.all ⇒ Object
CLASS METHODS
34 35 36 |
# File 'lib/cats_to_adopt/cat.rb', line 34 def self.all @@all end |
.print_cats ⇒ Object
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 |
#print_cat_info ⇒ Object
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 |