2.2. Crafting an object: The behavior of a ticket

A ticket is a familiar object, with a known set of properties and behaviors. Let’s take a high-level view at what we expect a ticket-like Ruby object to do and to know about itself.

2.2.1. The ticket object, behavior first

A ticket object should be able to provide data about itself. It should field requests for information about the event it’s for: when, where, name of event, performer, which seat, and how much it costs.

When asked, the ticket will provide the following information, based on an imaginary public reading by Mark Twain in 1903:

Town Hall
Author's reading
Mark Twain
Second Balcony, row J, seat 12

The goal is to create an object from which we can easily get all this ...

Get The Well-Grounded Rubyist, 2nd Edition now with the O’Reilly learning platform.

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