Skip to content

Instantly share code, notes, and snippets.

@ssaunier
Created October 17, 2014 07:32
Show Gist options
  • Save ssaunier/f95ac9e983032bcbe396 to your computer and use it in GitHub Desktop.
Save ssaunier/f95ac9e983032bcbe396 to your computer and use it in GitHub Desktop.
cat.rb
class Cat
def initialize(name, color)
@name = name
@color = color
@alive = true
@color_history = [ color ]
end
attr_reader :name, :color, :color_history
def dye(new_color)
@color = new_color
@color_history << @color
end
def meow
puts "Meow!" if alive?
end
def die!
@alive = false
end
def alive?
@alive
end
# METHODE DE CLASSE
def self.category
"Felin"
end
attr_writer :color
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment