@JRubyMethod(visibility = PRIVATE)
  @Override
  public IRubyObject initialize_copy(IRubyObject other) {
    RubyStringIO otherIO =
        (RubyStringIO)
            TypeConverter.convertToType(other, getRuntime().getClass("StringIO"), "to_strio");

    if (this == otherIO) return this;

    data = otherIO.data;
    if (otherIO.isTaint()) setTaint(true);

    return this;
  }
  @JRubyMethod(meta = true, rest = true)
  public static IRubyObject open(
      ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) {
    RubyStringIO strio =
        (RubyStringIO) ((RubyClass) recv).newInstance(context, args, Block.NULL_BLOCK);
    IRubyObject val = strio;

    if (block.isGiven()) {
      try {
        val = block.yield(context, strio);
      } finally {
        strio.doFinalize();
      }
    }
    return val;
  }
Esempio n. 3
0
 public static IRubyObject open(
     ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) {
   return org.jruby.ext.stringio.RubyStringIO.open(context, recv, args, block);
 }