Esempio n. 1
0
  @JRubyMethod(name = "+", required = 1, compat = CompatVersion.RUBY1_9)
  public IRubyObject op_plus19(ThreadContext context, IRubyObject other) {
    checkOpCoercion(context, other);
    if (other instanceof RubyTime) {
      throw getRuntime().newTypeError("time + time ?");
    }
    other = other.callMethod(context, "to_r");

    long adjustment = new Double(RubyNumeric.num2dbl(other) * 1000000).longValue();
    return opPlusCommon(adjustment);
  }
Esempio n. 2
0
 @JRubyMethod(name = "-", required = 1, compat = CompatVersion.RUBY1_9)
 public IRubyObject op_minus19(ThreadContext context, IRubyObject other) {
   checkOpCoercion(context, other);
   if (other instanceof RubyTime) return opMinus((RubyTime) other);
   return opMinusCommon(other.callMethod(context, "to_r"));
 }