> That's a very elegant solution. Does IO funnel all it's
> writes through "write"? Including things like putc? And where
> would I look to find this out? Is it only in the source code?

AFAIK, yes. Yes. In the source code. Probably.

> Last question: what does "self" do on the line below "class
> << io"

The common way to define a method of an object is this:

 class << an_object
   def method
     # ...
   end
 end

The problem is scope: variables declared before "class <<
an_object" aren't available within the "class << an_object"
block. (And variables declared before "def method" aren't
available within the "def method" block. But that can be worked
around by using "define_method(method)".) Defining a method
both within the context of "an_object" and within the local
scope of variables, can be achieved with this:

 class << an_object
   self
 end.module_eval do
   define_method(method) do
     # ...
   end
 end

gegroet,
Erik V. - http://www.erikveen.dds.nl/