This cookbook is aimed at people who know at least a little bit of Ruby, or who know a fair amount about programming in general. This book isn't a Ruby tutorial, but if you're already familiar with a few other programming languages, you should be able to pick up Ruby by going through the first 10 chapters of this book. This book contains recipes suitable for all skill levels. It focuses mainly on generic programming techniques, but it also covers specific application frameworks such as Ruby on Rails and GUI libraries, as well as best practices such as unit testing. I discuss the book further in the context of the table of contents:
The book starts with six chapters covering Ruby's built-in data structures.
Chapter 1, Strings, contains recipes for building, processing, and manipulating strings of text. There are a few recipes specifically applicable to regular expressions (Recipes 1.17, 1.18, and 1.19).
Chapter 2, Numbers, covers the representation of different types of numbers: real numbers, complex numbers, arbitrary-precision decimals, and so on. It also includes Ruby implementations of common mathematical and statistical algorithms, and explains some Ruby quirks you'll run into if you create your own numeric types (Recipes 2.13 and 2.14).
Chapter 3, Date and Time, covers Ruby's two interfaces for dealing with time: the one based on the C time library, which may be familiar to you from other programming languages, and the one implemented in pure Ruby, which is more idiomatic.
Chapter 4, Arrays, introduces the array, Ruby's simplest compound data type.
Chapter 5, Hashes, covers the hash, Ruby's other basic compound data type.
Chapter 6, Files and Directories, covers techniques for reading, writing, and manipulating files. This chapter also covers Ruby's standard libraries for searching and manipulating the filesystem.
The next four are more abstract and are about Ruby idiom and philosophy.
Chapter 7, Code Blocks and Iteration, contains recipes that explore the possibilities of Ruby's code blocks, also known as closures.
Chapter 8, Objects and Classes, contains recipes for writing different types of classes and methods, and a few recipes that demonstrate capabilities of all Ruby objects such as freezing and cloning.
Chapter 9, Modules and Namespaces, covers Ruby's modules. These constructs are used to "mix" new behavior into existing classes and to segregate functionality into different namespaces.
Chapter 10, Reflection and Metaprogramming, covers techniques for programatically exploring and modifying Ruby class definitions.
The next three chapters talk about specific file formats and Ruby.
Chapter 11, XML and HTML, shows how to handle the most popular data interchange formats. The chapter deals mostly with parsing other people's XML documents and web pages (see Recipe 11.9).
Chapter 12, Graphics and Other File Formats, covers data interchange formats other than XML and HTML, with a special focus on generating and manipulating graphics.
Chapter 13, Databases and Persistence, covers the best Ruby interfaces to data storage formats. This chapter demonstrates everything from different ways of serializing data and indexing text, to the Ruby client libraries for popular SQL databases, to full-blown abstraction layers like ActiveRecord that save you from having to write SQL at all.
Currently the most popular use of Ruby is in network applications, mostly through Ruby on Rails. There are three chapters devoted to different types of applications.
Chapter 14, Internet Services, kicks off our networking coverage by illustrating a wide variety of clients and servers written with Ruby libraries.
Chapter 15, Web Development: Ruby on Rails, covers the web application framework that's been driving so much of Ruby's recent popularity.
Chapter 16, Web Services and Distributed Programming, covers two techniques for sharing information between computers during a Ruby program.
Next are three chapters on the auxilliary tasks that surround the main programming work of a project.
Chapter 17, Testing, Debugging, Optimizing, and Documenting, focuses mainly on handling exception conditions and creating unit tests for your code. There are also several recipes on the processes of debugging and optimization.
Chapter 18, Packaging and Distributing Software, mainly deals with Ruby's Gem packaging system and the RubyForge server that hosts many gem files. The chapter also shows you how to create and distribute gems for your own projects.
Chapter 19, Automating Tasks with Rake, covers the most popular Ruby build tool.
The book closes with four chapters on miscellaneous topics.
Chapter 20, Multitasking and Multithreading, shows how to use threads to do more than one thing at once, and how to use Unix subprocesses to run external commands.
Chapter 21, User Interface, discusses the command-line interface, character-based GUIs with Curses and HighLine, GUI toolkits for various platforms, and more obscure kinds of user interfaces (Recipe 21.11).
Chapter 22, Extending Ruby with Other Languages, focuses on hooking up Ruby to other languages, either for performance or to get access to more libraries. There is one recipe about JRuby, the Ruby implementation that runs on the Java Virtual Machine (Recipe 22.5).
Chapter 23, System Administration, is full of self-contained programs for doing administrative tasks, usually using techniques from other chapters. The recipes have a heavy focus on Unix administration, but there are some resources for Windows users (including Recipe 23.2), and some cross-platform scripts.