Front cover image for Eloquent Ruby

Eloquent Ruby

Russ Olsen
Print Book, English, ©2011
Addison-Wesley, Upper Saddle River, NJ, ©2011
xxvii, 413 pages : illustrations ; 24 cm
9780321584106, 0321584104
676726142
pt. 1. The Basics
Write code that looks like Ruby
Choose the right control structure
Take advantage of Ruby's smart collections
Take advantage of Ruby's smart strings
Find the right string with regular expressions
Use symbols to stand for something
Treat everything like an object-because everything is
Embrace dynamic typing
Write specs!
pt. 2. Classes, Modules, and Blocks
Construct your classes from short, focused methods
Define operators respectfully
Create classes that understand equality
Get the behavior you need with Singleton and Class methods
Use class instance variables
Use modules as name spaces
Use modules as mixins
Use blocks to iterate
Execute around with a block
Save blocks to execute later
pt. 3. Metaprogramming
Use hooks to keep your program informed
Use method_missing for flexible error handling
Use method_missing for delegation
Use method_missing to build flexible APIs
Update existing classes with Monkey Patching
Create self-modifying classes
Create classes that modify their subclasses
pt. 4. Pulling it all Together
Invent internal DSLs
Build external DSLs for flexible syntax
Package your programs as gems
Know your Ruby implementation
Keep an open mind to go with those open classes
Appendix: Going further