示例#1
0
 // @RubyLevelMethod(name="collect!")
 public RubyValue collect_danger(RubyBlock block) {
   RubyArray a = (RubyArray) RubyAPI.callPublicNoArgMethod(this, block, RubyID.intern("collect"));
   clear();
   for (int i = 0; i < a.size(); i++) {
     add(a.get(i));
   }
   return this;
 }
示例#2
0
  public RubyString appendString(RubyValue v) {
    if (v instanceof RubyString) {
      return appendString((RubyString) v);
    } else {
      RubyValue r = RubyAPI.callPublicNoArgMethod(v, null, RubyID.toSID);
      if (r instanceof RubyString) return appendString((RubyString) r);

      return ObjectFactory.createString(r.toString());
    }
  }
示例#3
0
  public int appendString2(RubyValue v) {
    RubyString str = null;
    if (v instanceof RubyString) {
      str = (RubyString) v;
    } else {
      RubyValue r = RubyAPI.callPublicNoArgMethod(v, null, RubyID.toSID);
      str = (RubyString) r;
    }

    appendString(str);

    return str.length();
  }