In the Ruby Cookbook preface, the authors begin by saying "Life is Short." Following with, and I paraphrase, "This book is meant to save you time… but a span of time is also a piece of your life. Our lives are better spent creating new things than… trying to solve problems that have already been solved." The authors hope that by writing this book, they can save you much more of your time than they spent creating the book. As has been my experience with the Cookbook series, their hope is well founded.
Ruby Cookbook is geared toward those who have some experience with Ruby or those who have a strong general background in other programming languages and are wanting to learn Ruby. If you are familiar with a number of programming languages, studying through the first ten chapters should get you up to speed quite nicely.
Ruby is an object-oriented scripting language that originated from Japan. It takes some of the best features from some of the best languages and combines them to make a simple and easy to use yet powerful system for processing tasks. It is freely available as open source software and is available on many platforms including Windows, Mac OS X and Linux.
The Ruby Cookbook contains 23 chapters broken down into loosely six functional areas; Data Structures, Idiom and Philosophy, Storing Data, Applications, Programming Techniques, and Miscellaneous Techniques. You won't find these titles explicitly listed in the book, but for organization (and so I don't have to step through each chapter) I will present, my discussion using them. Each recipe begins with a problem statement. It then follows up with the solution so if you want, you can be done and get on with your life. There then is a discussion if you want to learn more about the solution. It ends with a "See Also" which will give you addition information if the discussion is not enough
In data Structures (chapters 1 thru 6), the authors cover the built in data structures used by the Ruby language. They cover strings, numbers, dates and time, arrays, hashes, files and directories. These deal with strict algorithmic problems. Some are as simple as 1.10's "Changing the Case of a String", some are more complex such as 4.15's "Partitioning or Classifying a Set" in which you want to partition an array based on some attribute of its elements.