Chapter 1: Write Code That Looks Like Ruby
Camels for Classes, Snakes Everywhere Else
Parentheses Are Optional but Are Occasionally Forbidden
Chapter 2: Choose the Right Control Structure
Use the Modifier Forms Where Appropriate
Chapter 3: Take Advantage of Ruby’s Smart Collections
Instant Arrays and Hashes from Method Calls
Running Through Your Collection
Rely on the Order of Your Hashes
Chapter 4: Take Advantage of Ruby’s Smart Strings
The String: A Place for Your Lines, Characters, and Bytes
Chapter 5: Find the Right String with Regular Expressions
Matching One Character at a Time
Sets, Ranges, and Alternatives
Chapter 6: Use Symbols to Stand for Something
Optimized to Stand for Something
Chapter 7: Treat Everything Like an Object—Because Everything Is
A Quick Review of Classes, Instances, and Methods
The Importance of Being an Object
Public, Private, and Protected
Chapter 8: Embrace Dynamic Typing
Shorter Programs, But Not the Way You Think
Required Ceremony Versus Programmer-Driven Clarity
Test::Unit: When Your Documents Just Have to Work
A Tidy Spec Is a Readable Spec
PART II: Classes, Modules, and Blocks
Chapter 10: Construct Your Classes from Short, Focused Methods
Chapter 11: Define Operators Respectfully
Chapter 12: Create Classes That Understand Equality
An Identifier for Your Documents
Double Equals for Everyday Use
Broadening the Appeal of the == Method
Triple Equals for Case Statements
Hash Tables and the eql? Method
Building a Well-Behaved Hash Key
Chapter 13: Get the Behavior You Need with Singleton and Class Methods
Class Methods: Singletons in Plain Sight
Chapter 14: Use Class Instance Variables
A Quick Review of Class Variables
Getting Control of the Data in Your Class
Class Instance Variables and Subclasses
Adding Some Convenience to Your Class Instance Variables
Chapter 15: Use Modules as Name Spaces
A Place for Your Stuff, with a Name
A Home for Those Utility Methods
Building Modules a Little at a Time
Treat Modules Like the Objects That They Are
Chapter 16: Use Modules as Mixins
Chapter 17: Use Blocks to Iterate
Enumerable: Your Iterator on Steroids
Chapter 18: Execute Around with a Block
When It Absolutely Must Happen
Setting Up Objects with an Initialization Block
Dragging Your Scope along with the Block
Chapter 19: Save Blocks to Execute Later
Saving Code Blocks for Lazy Initialization
Chapter 20: Use Hooks to Keep Your Program Informed
Chapter 21: Use method_missing for Flexible Error Handling
Chapter 22: Use method_missing for Delegation
The Promise and Pain of Delegation
The Trouble with Old-Fashioned Delegation
The method_missing Method to the Rescue
More Discriminating Delegation
Chapter 23: Use method_missing to Build Flexible APIs
Building Form Letters One Word at a Time
Magic Methods from method_missing
It’s the Users That Count—All of Them
Chapter 24: Update Existing Classes with Monkey Patching
Renaming Methods with alias_method
Do Anything to Any Class, Anytime
Chapter 25: Create Self-Modifying Classes
Put Programming Logic in Your Classes
Class Methods That Change Their Class
Chapter 26: Create Classes That Modify Their Subclasses
Subclassing Is (Sometimes) Hard to Do
Class Methods That Build Instance Methods
Better Method Creation with define_method
The Modification Sky Is the Limit
PART IV: Pulling It All Together
Chapter 27: Invent Internal DSLs
Little Languages for Big Problems
Chapter 28: Build External DSLs for Flexible Syntax
Regular Expressions for Heavier Parsing
Chapter 29: Package Your Programs as Gems
Uploading Your Gem to a Repository
Chapter 30: Know Your Ruby Implementation
MRI: An Enlightening Experience for the C Programmer
YARV: MRI with a Byte Code Turbocharger
JRuby: Bending the “J” in the JVM