A real-world OOP example

Let's start by analyzing a Ruby on Rails project that I built for a client:

If you see the first line, I have a class called ApplicationController, which inherits from a class called ActionController::Base. The < symbol denotes inheritance in Ruby.

Make sure not to get the < symbol used for inheritance confused with the < symbol used with conditionals. The Ruby parser is smart enough to differentiate when you want to use one over the other.

What this code essentially means is that, ApplicationController has access to all the methods available in ActionController::Base. In this sense, the attributes and behavior of ...

Get Comprehensive Ruby Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.