Class
Classes in Ruby are first-class objects—each is an instance of class Class. Since Class is a subclass of Module, most of the behavior of Class is actually defined in the class Module (see Module). The Class class itself adds a small number of new methods.
You can create an anonymous class with Class.new and assign it to a variable and use it like a regularly defined class. If you assign it to a variable whose name starts with a capital letter, it’s treated as a constant and behaves exactly like a regularly defined class.
When a new class is defined (typically using class SomeName ... end), an object of type Class is created and assigned to a constant (SomeName, in this case). When SomeName.new is called to create a new object, the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access