Ruby is a multi-paradigm language and it supports object-oriented paradigms like any other OO language does. We can have modules, classes, methods, objects, inheritance, and so on.
Like any other object-oriented language, we can define modules and classes in Ruby. A module is generally used to encapsulate one or more classes and improve readability. In the next few chapters, we will see how defining modules can improve the quality of the code:
module <module_name> class <class_name> end end
For example, let's see the following code:
module Vehicle class Car end end
We can have constructor methods for the
class Car def initialize(manufacturer, cost) @manufacturer = manufacturer @cost ...