Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
$stdout changing?
Tim Mcd
3/10/2009 12:36:00 AM
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-...
.
2 Answers
Eric Hodel
3/10/2009 1:00:00 AM
0
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...
Robert Klemme
3/10/2009 9:28:00 AM
0
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)
>> =A0@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...
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
--=20
remember.guy do |as, often| as.you_can - without end
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
$stdout changing?
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password