private final IRubyObject at(ThreadContext context, int i) { final Ruby runtime = context.runtime; final Object array = getObject(); final int length = Array.getLength(array); if ( i < 0 ) i = i + length; if ( i >= 0 && i < length ) { return ArrayUtils.arefDirect(runtime, array, converter, i); } return context.nil; }
private final IRubyObject at(ThreadContext context, int i) { final Ruby runtime = context.runtime; final Object array = getObject(); final int length = Array.getLength(array); if ( i < 0 ) i = i + length; if ( i >= 0 && i < length ) { return ArrayUtils.arefDirect(runtime, array, converter, i); } return context.nil; }
public IRubyObject arefDirect(Ruby runtime, int intIndex) { return ArrayUtils.arefDirect(runtime, getValue(), javaConverter, intIndex); }
public IRubyObject arefDirect(Ruby runtime, int intIndex) { return ArrayUtils.arefDirect(runtime, getValue(), javaConverter, intIndex); }
public IRubyObject arefDirect(Ruby runtime, int intIndex) { return ArrayUtils.arefDirect(runtime, getValue(), javaConverter, intIndex); }
public IRubyObject arefDirect(Ruby runtime, int intIndex) { return ArrayUtils.arefDirect(runtime, getValue(), javaConverter, intIndex); }
@JRubyMethod public IRubyObject each(ThreadContext context, Block block) { Ruby runtime = context.runtime; int length = Array.getLength(getObject()); for (int i = 0; i < length; i++) { IRubyObject rubyObj = ArrayUtils.arefDirect(runtime, getObject(), converter, i); block.yield(context, rubyObj); } return this; }
@JRubyMethod public IRubyObject each(ThreadContext context, Block block) { Ruby runtime = context.runtime; int length = Array.getLength(getObject()); for (int i = 0; i < length; i++) { IRubyObject rubyObj = ArrayUtils.arefDirect(runtime, getObject(), converter, i); block.yield(context, rubyObj); } return this; }
@JRubyMethod public IRubyObject at(ThreadContext context, IRubyObject indexObj) { Ruby runtime = context.runtime; Object array = getObject(); int length = Array.getLength(array); long index = indexObj.convertToInteger().getLongValue(); if (index < 0) { index = index + length; } if (index >= 0 && index < length) { return ArrayUtils.arefDirect(runtime, array, converter, (int)index); } else { return context.nil; } }
@JRubyMethod public IRubyObject at(ThreadContext context, IRubyObject indexObj) { Ruby runtime = context.runtime; Object array = getObject(); int length = Array.getLength(array); long index = indexObj.convertToInteger().getLongValue(); if (index < 0) { index = index + length; } if (index >= 0 && index < length) { return ArrayUtils.arefDirect(runtime, array, converter, (int)index); } else { return context.nil; } }
@JRubyMethod(name = "[]") public final IRubyObject op_aref(ThreadContext context, IRubyObject arg) { if ( arg instanceof RubyRange ) return arrayRange(context, (RubyRange) arg); final int i = convertArrayIndex(arg); return ArrayUtils.arefDirect(context.runtime, getObject(), converter, i); }
@JRubyMethod(name = "[]") public IRubyObject op_aref(ThreadContext context, IRubyObject arg) { if (arg instanceof RubyInteger) { int index = (int)((RubyInteger)arg).getLongValue(); return ArrayUtils.arefDirect(context.runtime, getObject(), converter, index); } else { return getRange(context, arg); } }
@JRubyMethod(name = "[]", required = 1, rest = true) public IRubyObject op_aref(ThreadContext context, IRubyObject[] args) { if (args.length == 1 && args[0] instanceof RubyInteger) { int index = (int)((RubyInteger)args[0]).getLongValue(); return ArrayUtils.arefDirect(context.runtime, getObject(), converter, index); } else { return getRange(context, args); } }
@JRubyMethod(name = "[]") public final IRubyObject op_aref(ThreadContext context, IRubyObject arg) { if ( arg instanceof RubyRange ) return arrayRange(context, (RubyRange) arg); final int i = convertArrayIndex(arg); return ArrayUtils.arefDirect(context.runtime, getObject(), converter, i); }
@JRubyMethod(name = "[]") public IRubyObject op_aref(ThreadContext context, IRubyObject arg) { if (arg instanceof RubyInteger) { int index = (int)((RubyInteger)arg).getLongValue(); return ArrayUtils.arefDirect(context.runtime, getObject(), converter, index); } else { return getRange(context, arg); } }
@JRubyMethod(name = "[]", required = 1, rest = true) public IRubyObject op_aref(ThreadContext context, IRubyObject[] args) { if (args.length == 1 && args[0] instanceof RubyInteger) { int index = (int)((RubyInteger)args[0]).getLongValue(); return ArrayUtils.arefDirect(context.runtime, getObject(), converter, index); } else { return getRange(context, args); } }
@JRubyMethod public IRubyObject each(ThreadContext context, Block block) { final Ruby runtime = context.runtime; if ( ! block.isGiven() ) { // ... Enumerator.new(self, :each) return runtime.getEnumerator().callMethod("new", this, runtime.newSymbol("each")); } final Object array = getObject(); final int length = Array.getLength(array); for ( int i = 0; i < length; i++ ) { IRubyObject element = ArrayUtils.arefDirect(runtime, array, converter, i); block.yield(context, element); } return this; }
@JRubyMethod public IRubyObject each(ThreadContext context, Block block) { final Ruby runtime = context.runtime; if ( ! block.isGiven() ) { // ... Enumerator.new(self, :each) return runtime.getEnumerator().callMethod("new", this, runtime.newSymbol("each")); } final Object array = getObject(); final int length = Array.getLength(array); for ( int i = 0; i < length; i++ ) { IRubyObject element = ArrayUtils.arefDirect(runtime, array, converter, i); block.yield(context, element); } return this; }
@JRubyMethod public IRubyObject each_with_index(final ThreadContext context, final Block block) { final Ruby runtime = context.runtime; if ( ! block.isGiven() ) { // ... Enumerator.new(self, :each) return runtime.getEnumerator().callMethod("new", this, runtime.newSymbol("each_with_index")); } final boolean arity2 = block.getSignature().arity() == Arity.TWO_ARGUMENTS; final Object array = getObject(); final int length = Array.getLength(array); for ( int i = 0; i < length; i++ ) { IRubyObject element = ArrayUtils.arefDirect(runtime, array, converter, i); final RubyInteger index = RubyFixnum.newFixnum(runtime, i); if ( arity2 ) { block.yieldSpecific(context, element, index); } else { block.yield(context, RubyArray.newArray(runtime, element, index)); } } return this; }
@JRubyMethod public IRubyObject each_with_index(final ThreadContext context, final Block block) { final Ruby runtime = context.runtime; if ( ! block.isGiven() ) { // ... Enumerator.new(self, :each) return runtime.getEnumerator().callMethod("new", this, runtime.newSymbol("each_with_index")); } final boolean arity2 = block.getSignature().arity() == Arity.TWO_ARGUMENTS; final Object array = getObject(); final int length = Array.getLength(array); for ( int i = 0; i < length; i++ ) { IRubyObject element = ArrayUtils.arefDirect(runtime, array, converter, i); final RubyInteger index = RubyFixnum.newFixnum(runtime, i); if ( arity2 ) { block.yieldSpecific(context, element, index); } else { block.yield(context, RubyArray.newArray(runtime, element, index)); } } return this; }