From: Robert Klemme Date: 2006-12-29T18:20:12+09:00 Subject: Re: unsafe readline(), anything better? On 28.12.2006 22:09, Rob Muhlestein wrote: > I do love that Ruby let's me add to IO itself, which handles adding > @prev_read buffer to store the overrun in for next read and is what > I'll do and post for review. I would also consider the alternative of creating a SafeLineReader that can be stacked on *any* IO object (or rather any object that implements #read with the proper protocol) as input stream much the same way Java streams can be stacked. You gain flexibility but of course you loose the easy "I just need to open a file and it works". I do not have a clear bias either way because I love the simplicity of Ruby's IO classes but on the other hand you can also stuff too much into a single class. Yet another alternative is to put your code into a Module which you can mix in to any IO object. You can still decide to to that on a general basis for class IO and StringIO. Just my 0.02EUR... Kind regards robert