$stdout changing?

Is it possible for me to have output that go to the $stdout go through a
method instead? ie:

Have stuff go through this:

def write_to(str)
  @socket.send(str, 0)
end

?

···

--
Posted via http://www.ruby-forum.com/.

You can assign any object that responds to #write to $stdout.

See also:

http://blog.segment7.net/articles/2006/08/17/stdout-vs-stdout

···

On Mar 9, 2009, at 17:35, Tim Mcd wrote:

Is it possible for me to have output that go to the $stdout go through a
method instead? ie:

Have stuff go through this:

def write_to(str)
@socket.send(str, 0)
end

In this case IO#reopen seems more appropriate IMHO (if it works with
Sockets, which I did not verify). It's faster (no Ruby code needed)
and will also work for sub processes.

Kind regards

robert

···

2009/3/10 Eric Hodel <drbrain@segment7.net>:

On Mar 9, 2009, at 17:35, Tim Mcd wrote:

Is it possible for me to have output that go to the $stdout go through a
method instead? ie:

Have stuff go through this:

def write_to(str)
@socket.send(str, 0)
end

You can assign any object that responds to #write to $stdout.

See also:

http://blog.segment7.net/articles/2006/08/17/stdout-vs-stdout

--
remember.guy do |as, often| as.you_can - without end