RubyString stringData = null;
if (invoke(context, data, "respond_to?",
ruby.newSymbol("to_io").to_sym()).isTrue()) {
/* IO or other object that responds to :to_io */
RubyIO io =
(RubyIO) TypeConverter.convertToType(data,
ruby.getIO(),
"to_io");
// use unclosedable input stream to fix #495
source.setByteStream(new UncloseableInputStream(io.getInStream()));
} else {
if (invoke(context, data, "respond_to?",
ruby.newSymbol("string").to_sym()).isTrue()) {
/* StringIO or other object that responds to :string */
stringData = invoke(context, data, "string").convertToString();