Fork me on GitHub

Project Notes

#406 Eloquent Ruby

Book notes - Eloquent Ruby, by Russ Olsen. First published January 27, 2011. Second Edition currently in beta - due Q1 2026.

Notes

This was the book that finally helped me crack the core concepts of lambdas, meta-programming and DSLs.

The first edition is showing its age now - written in the ruby 1.9 era, but a new Second Edition is on the way, due later in 2026.

cover

Contents - First Edition

  • Part I. The Basics
    • Chapter 1. Write Code That Looks Like Ruby
    • Chapter 2. Choose the Right Control Structure
    • Chapter 3. Take Advantage of Ruby’s Smart Collections
    • Chapter 4. Take Advantage of Ruby’s Smart Strings
    • Chapter 5. Find the Right String with Regular Expressions
    • Chapter 6. Use Symbols to Stand for Something
    • Chapter 7. Treat Everything Like an Object—Because Everything Is
    • Chapter 8. Embrace Dynamic Typing
    • Chapter 9. Write Specs!
  • 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
    • Chapter 13. Get the Behavior You Need with Singleton and Class Methods
    • Chapter 14. Use Class Instance Variables
    • Chapter 15. Use Modules as Name Spaces
    • Chapter 16. Use Modules as Mixins
    • Chapter 17. Use Blocks to Iterate
    • Chapter 18. Execute Around with a Block
    • Chapter 19. Save Blocks to Execute Later
  • Part III. Metaprogramming
    • 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
    • Chapter 23. Use method_missing to Build Flexible APIs
    • Chapter 24. Update Existing Classes with Monkey Patching
    • Chapter 25. Create Self-Modifying Classes
    • Chapter 26. Create Classes That Modify Their Subclasses
  • Part IV. Pulling It All Together
    • Chapter 27. Invent Internal DSLs
    • Chapter 28. Build External DSLs for Flexible Syntax
    • Chapter 29. Package Your Programs as Gems
    • Chapter 30. Know Your Ruby Implementation
    • Chapter 31. Keep an Open Mind to Go with Those Open Classes

Source Code - Second Edition

Source code is available from the Pragmatic Programmers listing. Getting the sources:

wget https://media.pragprog.com/titles/eruby2/code/eruby2-code.zip
unzip eruby2-code.zip
rm eruby2-code.zip

Credits and References

About LCK#406
BooksRuby

This page is a web-friendly rendering of my project notes shared in the LittleCodingKata GitHub repository.

Project Source on GitHub Return to the LittleCodingKata Catalog
About LittleCodingKata

LittleCodingKata is my collection of programming exercises, research and code toys broadly spanning things that relate to programming and software development (languages, frameworks and tools).

These range from the trivial to the complex and serious. Many are inspired by existing work and I'll note credits and references where applicable. The focus is quite scattered, as I variously work on things new and important in the moment, or go back to revisit things from the past.

This is primarily a personal collection for my own edification and learning, but anyone who stumbles by is welcome to borrow, steal or reference the work here. And if you spot errors or issues I'd really appreciate some feedback - create an issue, send me an email or even send a pull-request.

Follow the Blog follow projects and notes as they are published in your favourite feed reader