From: Derek Peschel Date: 2001-10-22T16:53:27+09:00 Subject: [ruby-talk:22940] Most OO way to make a variation of the IO class? Hi everybody, Like other people on the list, I'm new to Ruby, and I'm quite pleased with the "feel" of it. I'm familiar with the concepts of OOP through Smalltalk and C++, although I haven't actually written a lot of OO code. I'm writing methods to translate between ASCII and FIO-DEC (a charcter set used on the PDP-1, in the early 1960's). Right now I'm worrying about the algorithms, since FIO-DEC uses case-shifts like the 5-bit Murray code or some of the modern Asian codes, but eventually I will want to use my methods in a larger program. And that leads up to my question. I can imagine a "FIO-DEC IO" class that's just like the ordinary IO except that it also translates. Is there a simple way to actually express that in Ruby? Hopefully the new translation code wouldn't have to worry about the implementation of the existing code; there would be a small number of new methods to write; and only the class names would have to be changed in the callers. Unfortunately I suspect that the OO "is-a" relationship is too strict to be relied on here. It would be nice if I could change the putc and getc methods and have puts and gets automatically change, or have I/O from/to strings work as easily as I/O from/to files, but that doesn't mean it's going to happen. Thanks for any insight, -- Derek