A class is a piece of code within a program that functions as a template or blueprint for creating multiple instances of a particular object.
The template provides initial values and behavior for each of these instances. Each instance is an object itself.
Suppose we want to create a
Cat class with three instance variables:
class Catdef initialize(name, color, age)@cat_name = name@cat_color = color@cat_age = ageendend
Now we can create a bunch of objects based off of the
mochi = Cat.new("Mochi", "Gray", 2)bean = Cat.new("Bean", "Black/Gray", 6)femi = Cat.new("Femme en Noir", "Black/White", 9)