class CatsToAdopt::Cat
Attributes
age[RW]
color[RW]
gender[RW]
id[RW]
location[RW]
name[RW]
profile_url[RW]
size[RW]
weight[RW]
Public Class Methods
all()
click to toggle source
CLASS METHODS
# File lib/cats_to_adopt/cat.rb, line 34 def self.all @@all end
new()
click to toggle source
INSTANCE METHODS save a cat when it's created
# File lib/cats_to_adopt/cat.rb, line 8 def initialize @@all << self end
print_cats()
click to toggle source
# 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
Public Instance Methods
add_cat_attributes(attributes)
click to toggle source
set additional attributes on a cat
# 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()
click to toggle source
prints detailed information for a cat
# 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