}
@JRubyMethod(name = "to_channel")
public static IRubyObject any_to_channel(ThreadContext context, IRubyObject self) {
// using IOChannel may not be the most performant way, but it's easy.
IOChannel channel;
if (self.respondsTo("read")) {
if (self.respondsTo("write") || self.respondsTo("<<")) {
channel = new IOChannel.IOReadableWritableByteChannel(self);
} else {
channel = new IOChannel.IOReadableByteChannel(self);