Robert Dober
3/19/2007 11:52:00 PM
On 3/19/07, Daniel Schierbeck <daniel.schierbeck@gmail.com> wrote:
> On Tue, 2007-03-20 at 07:18 +0900, Giles Bowkett wrote:
> > Is there an easy way to capture standard out in Ruby, so that "puts"
> > throws its output into a buffer instead of just popping up on the
> > screen?
>
> You can set the $stdout global variable to point to whatever object you
> like, as long as it adheres to a simple interface. Kernel#puts simply
> redirects to $stdout.
That is a good idea too, especially with this idiom
def xxx(..., out = $stdout)
Robert
>
>
> Cheers,
> Daniel
>
>
>
--
You see things; and you say Why?
But I dream things that never were; and I say Why not?
-- George Bernard Shaw