/** num_quo (1.8) * quo and fdiv in 1.8 just invokes "/" */ @JRubyMethod(name = {"quo", "fdiv"}, compat = CompatVersion.RUBY1_8) public IRubyObject quo(ThreadContext context, IRubyObject other) { return callMethod(context, "/", other); }
/** num_quo (1.8) * quo and fdiv in 1.8 just invokes "/" */ @JRubyMethod(name = {"quo", "fdiv"}, compat = CompatVersion.RUBY1_8) public IRubyObject quo(ThreadContext context, IRubyObject other) { return callMethod(context, "/", other); }
/** num_modulo * */ @JRubyMethod(name = "modulo", compat = RUBY1_9) public IRubyObject modulo19(ThreadContext context, IRubyObject other) { return callMethod(context, "-", other.callMethod(context, "*", callMethod(context, "div", other))); }
/** num_modulo * */ @JRubyMethod(name = "modulo", compat = RUBY1_9) public IRubyObject modulo19(ThreadContext context, IRubyObject other) { return callMethod(context, "-", other.callMethod(context, "*", callMethod(context, "div", other))); }
/** num_modulo * */ @JRubyMethod(name = "modulo", compat = RUBY1_8) public IRubyObject modulo(ThreadContext context, IRubyObject other) { return callMethod(context, "%", other); }
/** num_modulo * */ @JRubyMethod(name = "modulo", compat = RUBY1_8) public IRubyObject modulo(ThreadContext context, IRubyObject other) { return callMethod(context, "%", other); }
/** num_abs * */ @JRubyMethod(name = "abs") public IRubyObject abs(ThreadContext context) { if (callMethod(context, "<", RubyFixnum.zero(getRuntime())).isTrue()) { return callMethod(context, "-@"); } return this; }
/** num_abs * */ @JRubyMethod(name = "abs") public IRubyObject abs(ThreadContext context) { if (callMethod(context, "<", RubyFixnum.zero(getRuntime())).isTrue()) { return callMethod(context, "-@"); } return this; }
/** num_div * */ @JRubyMethod(name = "div", compat = RUBY1_8) public IRubyObject div(ThreadContext context, IRubyObject other) { return callMethod(context, "/", other).convertToFloat().floor(); }
/** num_div * */ @JRubyMethod(name = "div", compat = RUBY1_8) public IRubyObject div(ThreadContext context, IRubyObject other) { return callMethod(context, "/", other).convertToFloat().floor(); }
/** num_nonzero_p * */ @JRubyMethod(name = "nonzero?") public IRubyObject nonzero_p(ThreadContext context) { if (callMethod(context, "zero?").isTrue()) { return getRuntime().getNil(); } return this; }
/** num_nonzero_p * */ @JRubyMethod(name = "nonzero?") public IRubyObject nonzero_p(ThreadContext context) { if (callMethod(context, "zero?").isTrue()) { return getRuntime().getNil(); } return this; }
/** num_div * */ @JRubyMethod(name = "div", compat = RUBY1_9) public IRubyObject div19(ThreadContext context, IRubyObject other) { if (other instanceof RubyNumeric) { RubyNumeric numeric = (RubyNumeric) other; if (numeric.zero_p(context).isTrue()) { throw context.runtime.newZeroDivisionError(); } } return callMethod(context, "/", other).callMethod(context, "floor"); }
/** num_div * */ @JRubyMethod(name = "div", compat = RUBY1_9) public IRubyObject div19(ThreadContext context, IRubyObject other) { if (other instanceof RubyNumeric) { RubyNumeric numeric = (RubyNumeric) other; if (numeric.zero_p(context).isTrue()) { throw context.runtime.newZeroDivisionError(); } } return callMethod(context, "/", other).callMethod(context, "floor"); }
/** rb_num_coerce_bit * coercion taking two arguments */ protected final IRubyObject coerceBit(ThreadContext context, String method, IRubyObject other) { if (!(other instanceof RubyFixnum) && !(other instanceof RubyBignum)) { RubyArray ary = doCoerce(context, other, true); IRubyObject x = ary.eltInternal(0); IRubyObject y = ary.eltInternal(1); if (!(x instanceof RubyFixnum) && !(x instanceof RubyBignum) && !(y instanceof RubyFixnum) && !(y instanceof RubyBignum)) { coerceFailed(context, other); } return x.callMethod(context, method, y); } return callMethod(context, method, other); }
/** rb_num_coerce_bit * coercion taking two arguments */ protected final IRubyObject coerceBit(ThreadContext context, String method, IRubyObject other) { if (!(other instanceof RubyFixnum) && !(other instanceof RubyBignum)) { RubyArray ary = doCoerce(context, other, true); IRubyObject x = ary.eltInternal(0); IRubyObject y = ary.eltInternal(1); if (!(x instanceof RubyFixnum) && !(x instanceof RubyBignum) && !(y instanceof RubyFixnum) && !(y instanceof RubyBignum)) { coerceFailed(context, other); } return x.callMethod(context, method, y); } return callMethod(context, method, other); }
/** num_remainder * */ @JRubyMethod(name = "remainder") public IRubyObject remainder(ThreadContext context, IRubyObject dividend) { IRubyObject z = callMethod(context, "%", dividend); IRubyObject x = this; RubyFixnum zero = RubyFixnum.zero(getRuntime()); if (!equalInternal(context, z, zero) && ((x.callMethod(context, "<", zero).isTrue() && dividend.callMethod(context, ">", zero).isTrue()) || (x.callMethod(context, ">", zero).isTrue() && dividend.callMethod(context, "<", zero).isTrue()))) { return z.callMethod(context, "-", dividend); } else { return z; } }
/** num_remainder * */ @JRubyMethod(name = "remainder") public IRubyObject remainder(ThreadContext context, IRubyObject dividend) { IRubyObject z = callMethod(context, "%", dividend); IRubyObject x = this; RubyFixnum zero = RubyFixnum.zero(getRuntime()); if (!equalInternal(context, z, zero) && ((x.callMethod(context, "<", zero).isTrue() && dividend.callMethod(context, ">", zero).isTrue()) || (x.callMethod(context, ">", zero).isTrue() && dividend.callMethod(context, "<", zero).isTrue()))) { return z.callMethod(context, "-", dividend); } else { return z; } }