private void numericStep(ThreadContext context, Ruby runtime, IRubyObject step, Block block) { final String method = isExclusive ? "<" : "<="; IRubyObject beg = begin; long i = 0; while (beg.callMethod(context, method, end).isTrue()) { block.yield(context, beg); i++; beg = begin.callMethod(context, "+", RubyFixnum.newFixnum(runtime, i).callMethod(context, "*", step)); } }
private void numericStep(ThreadContext context, Ruby runtime, IRubyObject step, Block block) { final String method = isExclusive ? "<" : "<="; IRubyObject beg = begin; long i = 0; while (beg.callMethod(context, method, end).isTrue()) { block.yield(context, beg); i++; beg = begin.callMethod(context, "+", RubyFixnum.newFixnum(runtime, i).callMethod(context, "*", step)); } }
private void numericStep19(ThreadContext context, Ruby runtime, IRubyObject step, Block block) { final String method = isExclusive ? "<" : "<="; IRubyObject beg = begin; long i = 0; while (beg.callMethod(context, method, end).isTrue()) { block.yield(context, beg); i++; beg = begin.callMethod(context, "+", RubyFixnum.newFixnum(runtime, i).callMethod(context, "*", step)); } }
private void numericStep19(ThreadContext context, Ruby runtime, IRubyObject step, Block block) { final String method = isExclusive ? "<" : "<="; IRubyObject beg = begin; long i = 0; while (beg.callMethod(context, method, end).isTrue()) { block.yield(context, beg); i++; beg = begin.callMethod(context, "+", RubyFixnum.newFixnum(runtime, i).callMethod(context, "*", step)); } }
private IRubyObject op_cmpCommon(ThreadContext context, IRubyObject other) { Ruby runtime = context.runtime; // deal with case when "other" is not a string if (other.respondsTo("to_str") && other.respondsTo("<=>")) { IRubyObject result = invokedynamic(context, other, OP_CMP, this); if (result.isNil()) return result; if (result instanceof RubyFixnum) { return RubyFixnum.newFixnum(runtime, -((RubyFixnum)result).getLongValue()); } else { return RubyFixnum.zero(runtime).callMethod(context, "-", result); } } return runtime.getNil(); }
private IRubyObject op_cmpCommon(ThreadContext context, IRubyObject other) { Ruby runtime = context.runtime; // deal with case when "other" is not a string if (other.respondsTo("to_str") && other.respondsTo("<=>")) { IRubyObject result = invokedynamic(context, other, OP_CMP, this); if (result.isNil()) return result; if (result instanceof RubyFixnum) { return RubyFixnum.newFixnum(runtime, -((RubyFixnum)result).getLongValue()); } else { return RubyFixnum.zero(runtime).callMethod(context, "-", result); } } return runtime.getNil(); }
} else { // Date, DateTime int prec = width - 3; IRubyObject power = context.runtime.newFixnum(10).callMethod("**", context.runtime.newFixnum(prec)); IRubyObject truncated = sub_millis.callMethod(context, "numerator").callMethod(context, "*", power); truncated = truncated.callMethod(context, "/", sub_millis.callMethod(context, "denominator"));
} else { // Date, DateTime int prec = width - 3; IRubyObject power = context.runtime.newFixnum(10).callMethod("**", context.runtime.newFixnum(prec)); IRubyObject truncated = sub_millis.callMethod(context, "numerator").callMethod(context, "*", power); truncated = truncated.callMethod(context, "/", sub_millis.callMethod(context, "denominator"));