O'Reilly logo

Ruby Phrasebook by Jason Clinton

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 4. Working with Objects

Working in Ruby is a joy because there is an internal consistency to the design. This consistency leads to expected (“least surprising”) behavior throughout the core Ruby classes, and this section is about that design. First, some ground rules:

An important detail to remember when working with Ruby is that all objects are subclassed from Object in some way; indeed, every object class that you create yourself will be a subclass of the class Class; in turn, Class is a subclass of Object. As I mention later, every new class also mixes in methods and properties of the Module class.

Object also mixes in methods from the Kernel module. This ensures that methods such as #gets, #puts, and #p work no matter which scope you ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required