At Fri, 9 Jul 2004 21:14:38 +0900,
Michael Neumann wrote in [ruby-talk:105707]:
> Is the following patch valuable?
> It doesn't work if you require readbytes before stringio!
I don't like this, because there are other IO-like classes,
Zlib::GzipReader in bundled library for instance.
I agree.
Instead, what about separating such class-independent methods
to a couple of modules so those classes can include them?
Yes, that's a better idea.
Regards,
Michael
···
On Fri, Jul 09, 2004 at 10:49:45PM +0900, nobu.nokada@softhome.net wrote:
How about putting all methods that depend on read into a module
ReadMixin (another better name for it?). For readbytes.rb this would
look like:
module ReadMixin
def readbytes(n)
...
end
end
class IO
include ReadMixin
end
Maybe IO and all similar classes could by default mix in the ReadMixin
module, so that readbytes.rb would only have to extend the ReadMixin
module for the readbytes method. Of course we'd also need an empty
ReadMixin module in Ruby by default.
Regards,
Michael
···
On Mon, Jul 12, 2004 at 02:28:38AM +0900, Michael Neumann wrote:
On Fri, Jul 09, 2004 at 10:49:45PM +0900, nobu.nokada@softhome.net wrote:
> Hi,
>
> At Fri, 9 Jul 2004 21:14:38 +0900,
> Michael Neumann wrote in [ruby-talk:105707]:
> > Is the following patch valuable?
> > It doesn't work if you require readbytes before stringio!
>
> I don't like this, because there are other IO-like classes,
> Zlib::GzipReader in bundled library for instance.
I agree.
> Instead, what about separating such class-independent methods
> to a couple of modules so those classes can include them?
At Mon, 12 Jul 2004 02:58:34 +0900,
Michael Neumann wrote in [ruby-talk:106007]:
> > > Is the following patch valuable?
> > > It doesn't work if you require readbytes before stringio!
> >
> > I don't like this, because there are other IO-like classes,
> > Zlib::GzipReader in bundled library for instance.
>
> I agree.
>
> > Instead, what about separating such class-independent methods
> > to a couple of modules so those classes can include them?
>
> Yes, that's a better idea.
How about putting all methods that depend on read into a module
ReadMixin (another better name for it?). For readbytes.rb this would
look like:
It was exactly what I wrote, except for the name. I thought
IO::Readable and IO::Writable instead.