From: Jeremy Bopp Date: 2011-01-05T11:10:49+09:00 Subject: [ruby-core:34075] Re: [ruby-core:34068] Re: [ruby-core:34017] Re: [ruby-core:34012] Re: Why doesn’t StringIO implement #freeze? On 01/04/2011 01:49 PM, Nikolai Weibull wrote: > The more I think about it, why is the IO code not more modularized? > Why do we need a completely separate implementation of IO where the > ���base��� object is a String? At least for the output part of it, it > seems that implementing #write would be sufficient to include a module > containing methods like #putc, #print, #puts, #printf, and similar. > Most of this would be true for reading as well, if a proper interface > was defined. I wondered this exact same thing when I needed to implement some IO-like filters in my ZIP library. My solution was to create a module that can provide most of the read, write, and seek methods equivalent to those provided by IO to any class that implements a few basic methods of its own (https://github.com/javanthropus/io-like). Sadly, it doesn't support Ruby 1.9 interfaces yet, but 1.8.6 and 1.8.7 are supported. It would be great if Ruby could provide more of a generic IO framework and avoid the potential duplication of code and/or logic used to create IO-like objects. -Jeremy