Section 2. Objects, Classes, and Modules

Like many modern programming languages, Ruby is object oriented. However, Ruby could be considered to be a purer object-oriented language than many. To see what I mean, let’s look closer at that expression 30.minutes.ago from the previous example. You might have naturally assumed that it is a bit of syntactic sugar, something that the Ruby interpreter intercepts and translates into something real like Time.now - 30*60 upon execution. Indeed, that is how it would have to work in languages such as C++, Java, and PHP, where integers, floats, and sometimes strings are treated as primitives below the OOP framework. In Ruby, however, everything is an object—even integers—as the following example demonstrates. ...

Get Rubyisms in Rails now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.