Confident Ruby

Written by Avdi Grimm
In these pages you’ll find:

  • 32 patterns for writing confident code.
  • How to avoid the “MacGyver method”—a step-by-step guide to thinking about methods in terms of the story they tell rather than the building blocks that happen to be lying around.
  • The most comprehensive coverage anywhere of Ruby’s conversion methods and protocols. You’ll learn not just how to convert built-in objects from one to another, and when to use #to_a vs. #to_ary vs. Array(); but also how to adopt Ruby’s conversion conventions to make your own objects powerfully extensible.
  • How to streamline your code and eliminate repetitive conditionals with the Special Case and Null Object patterns… and how to avoid the gotchas that can come with naive implementations of these patterns.
  • Simple habits to eliminate the dreaded “NoMethodError for NilClass” exception.
  • How to make your methods more flexible by passing in behavior instead of data.
  • How to helpfully deliver results from your methods when the possible outcomes are more nuanced than “success” or “failure”.
  • An applied demonstration of refactoring two Open-Source Ruby projects using patterns from the book.
  • And much, much more… nearly 300 pages of material and hundreds of code listings.