Refine search
@JRubyMethod(required = 1) public IRubyObject each_with_object(final ThreadContext context, IRubyObject arg, Block block) { return block.isGiven() ? RubyEnumerable.each_with_objectCommon(context, this, block, arg) : enumeratorizeWithSize(context, this, "each_with_object", new IRubyObject[]{arg}, enumSizeFn(context)); }
private IRubyObject with_index_common(ThreadContext context, final Block block, final String rubyMethodName, IRubyObject arg) { final Ruby runtime = context.runtime; final int index = arg.isNil() ? 0 : RubyNumeric.num2int(arg); if ( ! block.isGiven() ) { return arg.isNil() ? enumeratorizeWithSize(context, this, rubyMethodName, enumSizeFn(context)) : enumeratorizeWithSize(context, this, rubyMethodName, new IRubyObject[]{runtime.newFixnum(index)}, enumSizeFn(context)); } return RubyEnumerable.callEach(runtime, context, this, new RubyEnumerable.EachWithIndex(block, index)); }
/** rb_ary_collect_bang * */ @JRubyMethod(name = "map!") public IRubyObject map_bang(ThreadContext context, Block block) { return block.isGiven() ? collectBang(context, block) : enumeratorizeWithSize(context, this, "map!", enumLengthFn()); }
@JRubyMethod public IRubyObject keep_if(ThreadContext context, Block block) { if (!block.isGiven()) { return enumeratorizeWithSize(context, this, "keep_if", enumLengthFn()); } select_bang(context, block); return this; }
/** rb_ary_collect_bang * */ @JRubyMethod(name = "collect!") public IRubyObject collect_bang(ThreadContext context, Block block) { return block.isGiven() ? collectBang(context, block) : enumeratorizeWithSize(context, this, "collect!", enumLengthFn()); }
/** rb_ary_cycle * */ @JRubyMethod(name = "cycle") public IRubyObject cycle(ThreadContext context, Block block) { if (!block.isGiven()) return enumeratorizeWithSize(context, this, "cycle", cycleSizeFn(context)); return cycleCommon(context, -1, block); }
@JRubyMethod(name = "select!") public IRubyObject select_bang(final ThreadContext context, final Block block) { if (block.isGiven()) return keep_ifCommon(context, block) ? this : context.nil; return enumeratorizeWithSize(context, this, "select!", enumSizeFn()); }
@JRubyMethod public static IRubyObject cycle(ThreadContext context, IRubyObject self, final Block block) { if (!block.isGiven()) { return enumeratorizeWithSize(context, self, "cycle", cycleSizeFn(context, self)); } return cycleCommon(context, self, -1, block); }
@JRubyMethod public IRubyObject keep_if(final ThreadContext context, final Block block) { if (block.isGiven()) { keep_ifCommon(context, block); return this; } return enumeratorizeWithSize(context, this, "keep_if", enumSizeFn()); }
@JRubyMethod(name = "select!") public IRubyObject select_bang(final ThreadContext context, final Block block) { if (block.isGiven()) return keep_ifCommon(context, block) ? this : context.nil; return enumeratorizeWithSize(context, this, "select!", enumSizeFn()); }
@JRubyMethod public IRubyObject keep_if(final ThreadContext context, final Block block) { if (block.isGiven()) { keep_ifCommon(context, block); return this; } return enumeratorizeWithSize(context, this, "keep_if", enumSizeFn()); }
@JRubyMethod public IRubyObject keep_if(ThreadContext context, Block block) { if (!block.isGiven()) { return enumeratorizeWithSize(context, this, "keep_if", enumLengthFn()); } select_bang(context, block); return this; }
@JRubyMethod(required = 1) public IRubyObject each_with_object(final ThreadContext context, IRubyObject arg, Block block) { return block.isGiven() ? RubyEnumerable.each_with_objectCommon(context, this, block, arg) : enumeratorizeWithSize(context, this, "each_with_object", new IRubyObject[]{arg}, enumSizeFn(context)); }
@JRubyMethod public static IRubyObject cycle(ThreadContext context, IRubyObject self, final Block block) { if (!block.isGiven()) { return enumeratorizeWithSize(context, self, "cycle", cycleSizeFn(context, self)); } return cycleCommon(context, self, -1, block); }
/** rb_ary_collect_bang * */ @JRubyMethod(name = "collect!") public IRubyObject collect_bang(ThreadContext context, Block block) { return block.isGiven() ? collectBang(context, block) : enumeratorizeWithSize(context, this, "collect!", enumLengthFn()); }
/** rb_ary_collect_bang * */ @JRubyMethod(name = "map!") public IRubyObject map_bang(ThreadContext context, Block block) { return block.isGiven() ? collectBang(context, block) : enumeratorizeWithSize(context, this, "map!", enumLengthFn()); }
/** rb_ary_cycle * */ @JRubyMethod(name = "cycle") public IRubyObject cycle(ThreadContext context, Block block) { if (!block.isGiven()) return enumeratorizeWithSize(context, this, "cycle", cycleSizeFn(context)); return cycleCommon(context, -1, block); }
@JRubyMethod public IRubyObject with_object(ThreadContext context, final IRubyObject arg, final Block block) { return block.isGiven() ? RubyEnumerable.each_with_objectCommon(context, this, block, arg) : enumeratorizeWithSize(context, this, "with_object", new IRubyObject[]{arg}, enumSizeFn(context)); }
@JRubyMethod public IRubyObject reverse_each(ThreadContext context, Block block) { return block.isGiven() ? reverseEach(context, block) : enumeratorizeWithSize(context, this, "reverse_each", enumLengthFn()); }
@JRubyMethod(name = {"map"}) public IRubyObject map19(ThreadContext context, Block block) { return block.isGiven() ? collect(context, block) : enumeratorizeWithSize(context, this, "map", enumLengthFn()); }