A class is an object-oriented programming construct that is used to define a type of object. It defines both the data and the behavior of the objects of that type. Classes are the building blocks of object-oriented programming.
Example:
class Dog
attr_accessor :name, :breed
def initialize(name, breed)
@name = name
@breed = breed
end
end
A module is a collection of methods and constants that can be included in classes. It is used to provide a namespace and prevent name clashes between similarly named methods.
Example:
module Dog
def bark
puts “Woof!”
end
end