@RubyLevelMethod(name = "extend") public static RubyValue extend(RubyValue receiver, RubyArray args) { for (RubyValue v : args) { RubyAPI.callPublicOneArgMethod(v, receiver, null, RubyID.extendObjectID); } return receiver; }
@RubyLevelMethod(name = "===") public static RubyValue objEqual(RubyValue receiver, RubyValue arg) { if (receiver == arg) { return RubyConstant.QTRUE; } else { boolean result = RubyAPI.callPublicOneArgMethod(receiver, arg, null, RubyID.equalID).isTrue(); return ObjectFactory.createBoolean(result); } }
// @RubyLevelMethod(name="=~") public RubyValue operator_match(RubyValue arg) { if (arg instanceof RubyRegexp) { RubyRegexp reg = (RubyRegexp) arg; int p = reg.matchPosition(toString()); if (p >= 0) { return ObjectFactory.createFixnum(p); } else { return RubyConstant.QNIL; } } else { return RubyAPI.callPublicOneArgMethod(arg, this, null, RubyID.matchID); } }
private RubyValue compare(RubyArray other_array) { int length = (size() <= other_array.size()) ? size() : other_array.size(); for (int i = 0; i < length; ++i) { RubyValue v = RubyAPI.callPublicOneArgMethod(get(i), other_array.get(i), null, RubyID.unequalID); if (!RubyAPI.testEqual(v, ObjectFactory.FIXNUM0)) { return v; } } if (size() == other_array.size()) { return ObjectFactory.FIXNUM0; } else if (size() > other_array.size()) { return ObjectFactory.FIXNUM1; } else { return ObjectFactory.FIXNUM_NEGATIVE_ONE; } }
@RubyLevelMethod(name = "extend") public static RubyValue extend(RubyValue receiver, RubyValue arg) { RubyAPI.callPublicOneArgMethod(arg, receiver, null, RubyID.extendObjectID); return receiver; }