Subclass IO

Hi!

I’m writing an application with a graphical (OpenGL) console, which is
running a Ruby interpreter internally. Obviously, I want all the output
that Ruby generates to be displayed in my graphics console. Now, I found
some piece of code using $defout to redirect the output done by print,
puts, etc…

So, I thought, I would be able to achieve this, if I implement my own IO
subclass, which I can then assign to $defout. Could anyone point me to
some information telling me what methods to implement for a working IO
subclass?

Thanks,
Marco

Hi,

···

At Thu, 17 Oct 2002 20:25:15 +0900, Marco Kögler wrote:

So, I thought, I would be able to achieve this, if I implement my own
IO subclass, which I can then assign to $defout. Could anyone point me
to some information telling me what methods to implement for a working
IO subclass?

$defout needs “write” method.


Nobu Nakada

Hi!

I’m writing an application with a graphical (OpenGL) console, which is
running a Ruby interpreter internally. Obviously, I want all the output
that Ruby generates to be displayed in my graphics console. Now, I found
some piece of code using $defout to redirect the output done by print,
puts, etc…

So, I thought, I would be able to achieve this, if I implement my own IO
subclass, which I can then assign to $defout. Could anyone point me to
some information telling me what methods to implement for a working IO
subclass?

Thanks,
Marco

You may not need to subclass IO. Just create a class or object that implements
:puts, and see if that works. If you get error messages about missing methods,
implement them.

If you want to know what methods are in IO, download ‘ri’ and run ‘ri IO’.

Cheers,
Gavin

···

From: “Marco Kögler” marco.koegler@web.de