16 October 2012 P5.0 (Printing)

Fifth printing. Updated for Ruby 1.9.3. For a complete list of updates and fixes, please see errata.

13 July 2012 P4.2

This release fixes all outstanding errata. It also removes the (now deprecated) iconv library documentation.

In preparation for a new printing of the paper book, we’ve experimented with a new layout. With slightly different typography and a new style for the standard library reference, the book now has about 10% fewer pages while retaining the same content. Trees around the world sleep better tonight.

Let us know what you think. (And, if we’ve introduced any errors in the process, please add errata.)



06 November 2011 P4.1

Addressed pending errata, and updated for the minor changes in RUby 1.9.3:

  • id moved to BasicObject
  • rand() can now take a range
  • new byteslice() and prepend() methods in String
  • new advise(), binwrite() and write() methods for IO, and new encoding-aware behavior of putc()
  • new endian modifiers for pack() and unpack() directives
  • added a section on ARGF
  • document new modifiers to strftime, and update table of strftime directives
  • document File::NULL (name of the null device)
  • new File mode constants
  • new methods private_constant() and public_constant() in Module
  • added library pages for IO::Console and IO::NONBLOCK

11 May 2011 P4. (Printing)

Fourth printing.

Fixes errata reported up until late April.

11 November 2010 P3.0 (Printing)

  • updated for Ruby 1.9.2
  • now available in mobi and epub formats
  • Extending Ruby and Sockets appendices removed and placed online

13 April 2009 P2.0 (Printing)

Fixed some minor errata. Main purpose of release is to prepare for a new printing.

08 April 2009 P1.01

We finally worked out the hyperlinking problems that caused some cross references to land on the incorrect page.

No content changes were made.

01 April 2009 P1.0 (Printing)

This is the version that has gone to the printers.

A big ”Thank you” to everyone who has contributed feedback and suggestions during the creation of this book.

05 February 2009 B1.14

Now Ruby 1.9.1 has shipped, we’re getting close to the final book:

  • Finalize content
  • Finalize index
  • Remove reference to MatchingData
  • Remove reference to Thread#(add|set)\trace\func
  • Mention RubyOSX installer
  • Document that -w will check indentation of \CF{end} matches opening construct.
  • Document optional second parameter to Module.const\_defined?.
  • Float.round} now accepts a precision. (Rational.ceil, Rational.floor, Rational.round, and Rational.truncate will also in the next release.)
  • loop now returns an enumerator if no block is given.
  • Add Integer.ord
  • Add a small section to the Metaprogramming chapter on the new constant lookup rules with instance_eval.
  • Change the tracing wrapper example in the Metaprogramming chapter to use unbound methods, rather than aliasing, to chain calls.
  • Remove reference to SOAP library, which is no longer distributed with Ruby.
  • Add -E and -U options to irb.
  • trap and kill can now take either a string or a symbol.
  • Methods Method.parameters, Proc.parameters, and UnboundMethod.parameters did not make it into 1.9.1, so removed the description for now.

I know there’s a problem with some cross references: we’ll fix those soon.

16 December 2008 B1.13

  • Update Socket library appendix
  • Update installation instructions now 1.9 has made its way into the various port systems.
  • Update the support appendix.
  • Documented the Giant VM Lock protocol in the Extending Ruby chapter.
  • Merged the mkmf reference into the Extending Ruby chapter.
  • Replaced Amrita with Haml in the templating section of the web chapter (because I couldn’t get Amrita to work with 1.9)
  • Documented new options for IO.popen and Kernel.exec/spawn/system.
  • Document the transcoding options for String.encode.
  • Blocks using { } and do/end can now take the same parameters that those written using →.
  • Added block form of Enumerator.new (thanks David Black for the heads up). Added new section on Enumerators to the Containers chapter.
  • Remove Symbol.===
  • New methods Method.parameters, Proc.parameters, and UnboundMethod.parameters.
  • Document the ^ modifier for Time.strftime.
  • != and !~ can now be overridden
  • Removed hpricot from IO chapter—-no longer builds under 1.9
  • Remove -K command line option now that KCODE is gone.
  • Document method and callee.
  • Document new symbol encoding rules.
  • Document new conversion protocols to_enum, to_path, to_regexp.
  • Global methods chomp, chop, gsub, and sub are back, but only with -p and -n command line switches.
  • Add Encoding.default_internal= and Encoding.default_external=

22 October 2008 B1.12

We’re getting close to being complete. Ruby 1.9 is stabilizing, and the book reflects the very latest build.

Perhaps the smallest change in this release is also the biggest. This book is no longer the third edition of Programming Ruby. Instead, it’s the first edition of Programming Ruby 1.9. We made this change because it seems likely that Ruby 1.8 will continue to be used for several years after the release of 1.9, and we wanted people to be able to get the 1.8 book during that time. If we’d called it a third edition, then book sellers would pull the existing book from their shelves.

Other changes in this B1.12 release:

  • Updated the Ruby Language chapter.
  • Updated the ObjectSpace and Reflection chapter.
  • New chapter on Regular Expressions consolidates information that was in Standard Types and the Language Reference chapters.
  • Document new name-based options for sprintf.
  • New method Encoding.names.
  • New methods Proc.source_location, Method.source_location, and UnboundMethod.source_location.
  • New “m0” option to pack and unpack create and read Base 64 strings with no newlines.
  • The base64 standard library has arisen from the dead.
  • Describe default_internal encoding, and change to String.encode. Add the -U command line option.
  • Document that 7-bit literal strings, symbols, etc now take file’s encoding, and not

25 September 2008 B1.11

  • Lots of changes to the Testing chapter now that mini/test is the new Test::Unit.
  • Setting ENV[’xxx’] to nil removes xxx from the environment.
  • Replace Complex#image with Complex#imaginary. Replace Complex#scalar? with Complex#real?.
  • Replace Numeric#image with Numeric#imaginary. Remove Numeric#im and Numeric#re. Replace Numeric#scalar?
    with Numeric#real?.
  • Added IO.binread.
  • Removed Encoding.base_encoding.
  • Added String#codepoints and String#each_codepoint.
  • Document :encoding parameter for Dir.new/open.
  • Document new standard library Prime.
  • Add Shoulda examples to Unit Testing chapter
  • strftime now supports %P and %s
  • Add Enumerable#each_with_object, Enumerator#each_with_object, and Enumerator#with_object.
  • Add Complex.rect, Complex.rectangular, Complex#magnitude, Complex#phase, Complex#rect, Complex#rectangular,
    Fixnum#magnitude, Float#magnitude, Numeric#abs2, Numeric#magnitude, Numeric#phase, Numeric#rect,
  • Remove Complex.generic?
  • Add File#absolute_path.
  • Add new section on the trust mechanism to Locking Ruby in the Safe, and document Object#trust, Object#untrust,
    and Object#untrusted?.
  • Reinstated the Hpricot example.
  • Updated the Duck Typing chapter (minor changes, and added a section on Symbol#to_proc.

19 August 2008 B1.10

  • Mild update of the IO tutorial chapter. Added a page on Hpricot, as it now installs on 1.9 (although it doesn’t yet run).
  • Swapped order of Containers and Modules chapters, as there were some dependencies I hadn’t spotted.
  • Added section on RSpec and Shoulda to the Unit Testing
  • New \CONST{RUBY\_ENGINE} constant.
  • The \C{Enumerator} class used to be defined under \C{Enumerable}. It is now a top-level class.
  • \CIM{Array.choice} is now called \CIM{Array.sample}. It can take an optional argument.
  • New method \CIM{Hash.default\_proc=}.
  • New method \CIM{IO.ungetbyte}.
  • “1.9”.succ change to \CIM{String.succ}
  • Fixed pending errata (thank you, Charlie O’Keefe)

08 July 2008 B1.09

  • Mild rewrite of Methods, Expressions, and Exceptions, tutorial chapters.
  • Added a new chapter on sharing functionality using inheritance and mixins.
  • Added a new chapter on packaging applications.
  • Removed Array.nitems
  • Removed Process::Status.to_int
  • Added IO.binmode?
  • Enumerable.count} now returns a count, not an Enumerator, if no block given.
  • Document def my\_method(*) syntax in the Methods chapter.
  • Addressed errata that can be addressed.

28 May 2008 B1.08

There’s a full list of changes in chapter 1, but this release has two separate thrusts.

1. All the recent library changes (including Symbol’s move away from being immediate and relative_require) are now in.

2. I’ve decided to rewrite the tutorial. It follows the same structure, but I wanted to bring it more up-to-date and use some real-life examples.

11 April 2008 B1.07

The major change in this release is the update of the complete standard library documentation (these are the libraries that come with Ruby that you have to require into your programs. There are a lot of changes:

  • The base64 library has been removed. Use Array#pack and String#unpack instead.
  • The much of the Complex and Rational libraries are now built in to the interpreter. However, requiring the external libraries adds additional functionally. In the case of Rational, this functionality is minimal.
  • The CMath library has been added.
  • The Enumerator library is now built in.
  • Added Fiber library (adds coroutine support to fibers).
  • Removed ftools (replaced by fileutils).
  • The Generator library has been removed (use Fibers).
  • Added notes on using irb from inside applications.
  • jcode is removed in favor of built-in encoding support.
  • The json library is added.
  • The matrix library no longer requires that you include mathn.
  • The mutex library is now built in.
  • parsedate has been removed. The Date class handles most of its functionality.
  • readbytes has been removed. IO now supports the method directly.
  • require_relative added.
  • Add description of Ripper.
  • Add description of SecureRandom.
  • I’ve omitted the shell library, as it seems more like a curiosity than something folks would use (and it’s broken under 1.9).
  • The soap library is removed.
  • I’ve omitted the sync library. It is broken under 1.9, and the monitor library seems to be cleaner.
  • Win32API is now deprecated in favor of using the DL library.

19 March 2008 B1.06

This release finishes the update of the standard library, adding 6 new classes and either adding or updating the descriptions of hundreds of methods. See the Changes chapter for a description of other updates in this release.

26 February 2008 B1.05

For this release, I’ve replaced the old Classes and Objects chapter with a brand new chapter on the basics of metaprogramming.



11 February 2008 B1.04

Sorry this one took so long: I’ve been waiting for 1.9 HEAD to stabilize again—for the last 3 weeks I’ve been unable to build the book against it.

The change log is at the front of the book. I’ve updated standard classes and modules up to Integer, and updated the Encoding chapter to reflect the new 1.9 defaults.

10 January 2008 B1.03

Updated through to the end of Ruby in Its Setting.

Added a new chapter on Character Encoding

A temporary Chapter One contains the list of changes for this release

13 December 2007 B1.02

13 December 2007 B1.01