A diagram of the Ruby Core object model

Written by Jerome's Adventures in Software - - Aggregated on Saturday October 5, 2013

I am a visual learner. A picture is worth a thousand words.

When I started learning Ruby, I could not find a decent diagram that would just sum up the Ruby classes, modules, and their hierarchy.

So I made mine.
By hand.
On an A4 sheet.

Here is the result (click for a full size view):

Most of Ruby’s guts at one glance: pretty neat, huh ?

Note: To have a decent layout, I only drew 70% of the Ruby 2 Core classes. All of the important ones are there, except Random, Time, GC and ObjectSpace: when I noticed, it was too late. :–)

What can we “draw” from this ?

Well, this model is pretty much what we would have expected:

So, everything makes sense and is quite simple actually! Except maybe the fact that a module is a class, and class inherits from module. Don’t worry, you will eventually wrap your head around it.

Going further

In addition to Ruby Core, the Ruby Standard Library contains many other very useful classes and modules, such as Date, Forwardable, SimpleDelegator, Net::HTTP, OpenStruct, etc.

This diagram does not explain the Ruby method lookup path, which takes eigenclasses, included modules and superclasses into account. I recommend reading this enlightening article from Practicing Ruby.

« What traffic do you get when mentioned … - Jerome's Adventures in Software

Jerome's Adventures in Software - First post »