Chapter 3. Organizing objects with classes

This chapter covers
  • Creating multiple objects with classes
  • Setting and reading object state
  • Automating creation of attribute read and write methods
  • Class inheritance mechanics
  • Syntax and semantics of Ruby constants

Creating a new object with Object.new—and equipping that object with its own methods, one method at a time—is a great way to get a feel for the object-centeredness of Ruby programming. But this approach doesn’t exactly scale; if you’re running an online box office and your database has to process records for tickets by the hundreds, you’ve got to find another way to create and manipulate ticket-like objects in your Ruby programs.

Sure enough, Ruby gives you a full ...

Get The Well-Grounded Rubyist, Third Edition 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.