@RubyLevelMethod(name = ">") public RubyValue opGt(RubyValue v) { if (v instanceof RubyFixnum) { return ObjectFactory.createBoolean(this.value_ > ((RubyFixnum) v).value_); } else if (v instanceof RubyFloat) { return ObjectFactory.createBoolean(this.value_ > v.toFloat()); } return coerceRelop(RubyID.gtID, v); }
@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 opEqual(RubyValue arg) { if (arg == this) { return RubyConstant.QTRUE; } if (arg instanceof RubyFixnum) { return ObjectFactory.createBoolean(this.value_ == ((RubyFixnum) arg).value_); } return RubyAPI.callOneArgMethod(arg, this, null, RubyID.equalID); }
@RubyLevelMethod(name = "respond_to?") public static RubyValue respond_to(RubyValue receiver, RubyArray args) { if (null == args || args.size() < 1) { int actual_argc = (null == args) ? 0 : args.size(); throw new RubyException( RubyRuntime.ArgumentErrorClass, "in `respond_to': wrong number of arguments (" + actual_argc + " for 1)"); } boolean include_private = (RubyConstant.QTRUE == args.get(1)); RubyID mid = RubyID.intern(args.get(0).toStr()); return ObjectFactory.createBoolean(hasMethod(receiver, mid, include_private)); }
// @RubyLevelMethod(name="==") public RubyValue opEqual(RubyValue v) { if (this == v) { return RubyConstant.QTRUE; } if (v instanceof RubyString) { RubyString str = ((RubyString) v); if ((this.sb_.length() == str.sb_.length() && this.cmp(str) == 0)) { return RubyConstant.QTRUE; } else { return RubyConstant.QFALSE; } } if (v.respondTo(RubyID.toStrID)) { return ObjectFactory.createBoolean(v.equals(this)); } else { return RubyConstant.QFALSE; } }
// @RubyLevelMethod(name="eql?") public RubyValue opEql(RubyValue v) { return ObjectFactory.createBoolean(equals(v, false)); }
// @RubyLevelMethod(name="empty?") public RubyValue empty_p() { return ObjectFactory.createBoolean(this.array_.isEmpty()); }
@RubyLevelMethod(name = "tainted?") public static RubyValue tainted(RubyValue receiver) { return ObjectFactory.createBoolean(receiver.tainted()); }
@RubyLevelMethod(name = "frozen?") public static RubyValue frozen(RubyValue receiver) { return ObjectFactory.createBoolean(receiver.frozen()); }
@RubyLevelMethod(name = "block_given?", alias = "iterator?", module = true) public static RubyValue blockGivenP(RubyValue receiver, RubyBlock block) { return ObjectFactory.createBoolean(null != block); }
@RubyLevelMethod( name = "==", alias = {"equal?", "eql?"}) public static RubyValue opEqual(RubyValue receiver, RubyValue arg) { return ObjectFactory.createBoolean(receiver == arg); }
@RubyLevelMethod(name = "instance_of?") public static RubyValue instanceOf(RubyValue receiver, RubyValue arg) { return ObjectFactory.createBoolean(receiver.getRubyClass().getRealClass() == arg); }
@RubyLevelMethod(name = "kind_of?", alias = "is_a?") public static RubyValue kindOf(RubyValue receiver, RubyValue arg) { return ObjectFactory.createBoolean(RubyAPI.isKindOf(arg, receiver)); }
// RHO_MOBILE // @RubyLevelMethod(name = "include?") public RubyValue include_p(RubyValue arg) { int nIndex = sb_.toString().indexOf(arg.toStr()); return ObjectFactory.createBoolean(nIndex >= 0); }