How do I make my own class that can be substituted for IO in order to e.g. redirect/capture input/output for some code that accepts an IO-like parameter? IO itself seems to be coupled to OS file descriptors and the only class I know of that mimics it without subclassing it is StringIO, which seems to just reimplement the entire interface.
I would think that the language would provide a straightforward way to do this but I can't find any information on the subject. Is there a mixin that implements the interface on top of a few primitives, as Enumerable does?