Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
29 lines (24 sloc) 682 Bytes
class Animal
@@animalCount = 0
attr_reader :breed,
:age,
:weight,
:last_vaccine
# The initialize method is a special Class method.
def initialize(breed:, age:, weight:, last_vaccine:)
@breed = breed
@age = age
@weight = weight
@last_vaccine = last_vaccine
@@animalCount += 1
end
# This is a Class method. They are useful when you need
# methods that work without being tied to any particular object.
def self.count
"There are #{@@animalCount} cute animals in our Ruby Farm!"
end
def vaccinated?
current_year = Time.now.year
current_year - @last_vaccine <= 1 ? true : false
end
end