-
Book Overview & Buying
-
Table Of Contents
Polished Ruby Programming - Second Edition
By :
One of the great aspects of Ruby is that even if you don't explicitly design your library for extensibility, the language itself offers ways to make the library extensible. Using the built-in language features makes it possible to extend a library, even if it wasn't designed for extensibility.
Ruby has many ways to modify the behavior of objects. Other than the immediate objects, which we discussed in Chapter 1, Getting the Most out of Core Classes, and objects that are frozen, all Ruby objects support extension by modifying the object's singleton class.
Commonly, libraries will define methods in classes. Let's say you are designing a Ruby library to manage books and users for physical libraries (those that lend out books such as this book). The physical library has many users, most of whom check out books on a regular basis. For each user, you want to track the books they have checked out, and for each book, you want to know...
Change the font size
Change margin width
Change background colour