il 16 Mar 2004 04:20:52 GMT, ggarramuno / aol.com (GGarramuno) ha
scritto::


>
>class MayaLog << IO
>     def sync()
>         MELLog( @buffer )
>         @buffer = nil
>     end
>end
>
>That is, everytime the stream reaches a newline and gets sync'ed, the buffer of
>the stream would get sent out to a C command of my own(MELLog) and would then
>be cleared.

would'nt a simple StringIO subclass work for this?
>> require 'stringio'
=> true
>> class MelLog < StringIO
>>  def sync
>>   STDERR.puts self.string
>>  end
>> end
=> nil
>> a=MelLog.new
=> #<MelLog:0x275ab60>
>> a.puts 'ciao'
=> nil
>> a.sync
ciao
=> nil

>Sadly, I am unable to find any docs describing inheriting from IO.  Anyone can
>help out?
>
I believe this has been noted sometimes.
Why we have a big hard to inherit IO Class?

It would be nice, imo,  to have some smaller modules mixed in IO and
easy to be imported in any other user defined class.
I.e. Output could be a mix-in based on print(), Input could just need
read() ( and probably we could have a Seekable module)