Contents

preface
acknowledgments
about this book
about the cover illustration

Part 1 Ruby foundations 1

Chapter 1 Bootstrapping your Ruby literacy
Basic Ruby language literacy
Anatomy of the Ruby installation
Ruby extensions and programming libraries
Out-of-the-box Ruby tools and applications
Summary

 
Chapter 2 Objects, methods, and local variables
Talking to objects
Crafting an object: the behavior of a ticket
The innate behaviors of an object
A close look at method arguments
What you can’t do in argument lists
Local variables and variable assignment
Summary

 
Chapter 3 Organizing objects with classes
Classes and instances
Instance variables and object state
Setter methods
Attributes and the attr_* method family
Inheritance and the Ruby class hierarchy
Classes as objects and message receivers
Constants up close
Nature vs. nurture in Ruby objects
Summary

 
Chapter 4 Modules and program organization
Basics of module creation and use
Modules, classes, and method lookup
The method_missing method
Class/module design and naming
Summary

 
Chapter 5 The default object (self), scope, and visibility
Understanding self, the current/default object
Determining scope
Deploying method-access rules
Writing and using top-level methods
Summary

 
Chapter 6 Control-flow techniques
Conditional code execution
Repeating actions with loops
Iterators and code blocks
Error handling and exceptions
Summary

Part 2 Built-in classes and modules

Chapter 7 Built-in essentials
Ruby’s literal constructors
Recurrent syntactic sugar
Bang (!) methods and “danger”
Built-in and custom to_* (conversion) methods
Boolean states, boolean objects, and nil
Comparing two objects
Inspecting object capabilities
Summary

 
Chapter 8 Strings, symbols, and other scalar objects
Working with strings
Symbols and their uses
Numerical objects
Times and dates
Summary

 
Chapter 9 Collection and container objects
Arrays and hashes in comparison
Collection handling with arrays
Hashes
Ranges
Sets
Exploring the set.rb source code
Summary

 
Chapter 10 Collections central: Enumerable and Enumerator
Gaining enumerability through each
Enumerable boolean queries
Enumerable searching and selecting
Element-wise enumerable operations
The relatives of each
The map method
Strings as quasi-enumerables
Sorting enumerables
Enumerators and the next dimension of enumerability
Enumerator semantics and uses
Enumerator method chaining
Summary

 
Chapter 11 Regular expressions and regexp-based string operations
What are regular expressions?
Writing regular expressions
Building a pattern in a regular expression
Matching, substring captures, and MatchData
Fine-tuning regular expressions with quantifiers, anchors, and modifiers
Converting strings and regular expressions to each other
Common methods that use regular expressions
Summary

 
Chapter 12 File, I/O, and system operations
How Ruby’s I/O system is put together
Basic file operations
Querying IO and File objects
Directory manipulation with the Dir class
File tools from the standard library
Summary

Part 3 Ruby dynamics

Chapter 13 Object individuation
Where the singleton methods are: the singleton class
Modifying Ruby’s core classes and modules
BasicObject as ancestor and class
Summary

 
Chapter 14 Callable and runnable objects
Basic anonymous functions: the Proc class
Creating functions with lambda and ->
Methods as objects
The eval family of methods
Parallel execution with threads
Issuing system commands from inside Ruby programs
Summary

 
Chapter 15 Callbacks, hooks, and runtime introspection
Callbacks and hooks
Interpreting object capability queries
Introspection of variables and constants
Tracing execution
Callbacks and method inspection in practice
Summary