/** nil_to_a * */ @JRubyMethod(name = "to_a") public static RubyArray to_a(ThreadContext context, IRubyObject recv) { return context.runtime.newEmptyArray(); }
public static IRubyObject constructRestArg(ThreadContext context, Object[] args, RubyHash keywordArguments, int required, int argIndex) { int argsLength = keywordArguments != null ? args.length - 1 : args.length; int remainingArguments = argsLength - required; if (remainingArguments <= 0) return context.runtime.newEmptyArray(); return RubyArray.newArrayMayCopy(context.runtime, (IRubyObject[]) args, argIndex, remainingArguments); }
/** nil_to_a * */ @JRubyMethod public static RubyArray to_a(ThreadContext context, IRubyObject recv) { return context.runtime.newEmptyArray(); }
@JRubyMethod public static IRubyObject dimensions(ThreadContext context, IRubyObject maybeArray) { Ruby runtime = context.runtime; if (!(maybeArray instanceof RubyArray)) { return runtime.newEmptyArray(); } RubyArray rubyArray = (RubyArray)maybeArray; RubyArray dims = runtime.newEmptyArray(); return dimsRecurse(context, rubyArray, dims, 0); }
public static IRubyObject constructRestArg(ThreadContext context, Object[] args, RubyHash keywordArguments, int required, int argIndex) { int argsLength = keywordArguments != null ? args.length - 1 : args.length; int remainingArguments = argsLength - required; if (remainingArguments <= 0) return context.runtime.newEmptyArray(); return RubyArray.newArrayMayCopy(context.runtime, (IRubyObject[]) args, argIndex, remainingArguments); }
/** nil_to_a * */ @JRubyMethod(name = "to_a") public static RubyArray to_a(ThreadContext context, IRubyObject recv) { return context.runtime.newEmptyArray(); }
private static IRubyObject constructRestArg(ThreadContext context, IRubyObject[] args, RubyHash keywordArguments, int required, int argIndex) { int argsLength = keywordArguments != null ? args.length - 1 : args.length; if ( required == 0 && argsLength == args.length ) { return RubyArray.newArray(context.runtime, args); } int remainingArguments = argsLength - required; if (remainingArguments <= 0) return context.runtime.newEmptyArray(); return RubyArray.newArrayMayCopy(context.runtime, args, argIndex, remainingArguments); }
@JRubyMethod public static IRubyObject dimensions(ThreadContext context, IRubyObject rubyArray, IRubyObject dims) { final Ruby runtime = context.runtime; if ( ! ( rubyArray instanceof RubyArray ) ) { return runtime.newEmptyArray(); } assert dims instanceof RubyArray; return calcDimensions(runtime, (RubyArray) rubyArray, (RubyArray) dims, 0); }
@JRubyMethod public static IRubyObject dimensions(ThreadContext context, IRubyObject rubyArray, IRubyObject dims) { final Ruby runtime = context.runtime; if ( ! ( rubyArray instanceof RubyArray ) ) { return runtime.newEmptyArray(); } assert dims instanceof RubyArray; return calcDimensions(runtime, (RubyArray) rubyArray, (RubyArray) dims, 0); }
private static IRubyObject constructRestArg(ThreadContext context, IRubyObject[] args, RubyHash keywordArguments, int required, int argIndex) { int argsLength = keywordArguments != null ? args.length - 1 : args.length; if ( required == 0 && argsLength == args.length ) { return RubyArray.newArray(context.runtime, args); } int remainingArguments = argsLength - required; if (remainingArguments <= 0) return context.runtime.newEmptyArray(); return RubyArray.newArrayMayCopy(context.runtime, args, argIndex, remainingArguments); }
@JRubyMethod public static IRubyObject dimensions(ThreadContext context, IRubyObject rubyArray) { return dimensions(context, rubyArray, context.runtime.newEmptyArray()); }
@Deprecated // not used public static RubyArray splatValue19(IRubyObject value) { if (value.isNil()) { return value.getRuntime().newEmptyArray(); } return arrayValue(value); }
@JRubyMethod public static IRubyObject dimensions(ThreadContext context, IRubyObject rubyArray, IRubyObject dims, IRubyObject index) { final Ruby runtime = context.runtime; if ( ! ( rubyArray instanceof RubyArray ) ) { return runtime.newEmptyArray(); } assert dims instanceof RubyArray; assert index instanceof RubyFixnum; final int i = (int) ((RubyFixnum) index).getLongValue(); return calcDimensions(runtime, (RubyArray) rubyArray, (RubyArray) dims, i); }
@JRubyMethod public static IRubyObject dimensions(ThreadContext context, IRubyObject maybeArray, IRubyObject dims, IRubyObject index) { Ruby runtime = context.runtime; if (!(maybeArray instanceof RubyArray)) { return runtime.newEmptyArray(); } assert dims instanceof RubyArray; assert index instanceof RubyFixnum; RubyArray rubyArray = (RubyArray)maybeArray; return dimsRecurse(context, rubyArray, (RubyArray)dims, (int)((RubyFixnum)index).getLongValue()); }
@JRubyMethod public static IRubyObject dimensions(ThreadContext context, IRubyObject rubyArray, IRubyObject dims, IRubyObject index) { final Ruby runtime = context.runtime; if ( ! ( rubyArray instanceof RubyArray ) ) { return runtime.newEmptyArray(); } assert dims instanceof RubyArray; assert index instanceof RubyFixnum; final int i = (int) ((RubyFixnum) index).getLongValue(); return calcDimensions(runtime, (RubyArray) rubyArray, (RubyArray) dims, i); }
public static RubyArray asArray(ThreadContext context, IRubyObject value) { RubyClass array = context.runtime.getArray(); IRubyObject tmp = TypeConverter.convertToTypeWithCheck19(value, array, "to_ary"); if (tmp.isNil()) { tmp = TypeConverter.convertToTypeWithCheck19(value, array, "to_a"); if (tmp.isNil()) return context.runtime.newEmptyArray(); } return (RubyArray) tmp; // converters will guarantee it is RubyArray or raise. }
public static RubyArray asArray(ThreadContext context, IRubyObject value) { RubyClass array = context.runtime.getArray(); IRubyObject tmp = TypeConverter.convertToTypeWithCheck19(value, array, "to_ary"); if (tmp.isNil()) { tmp = TypeConverter.convertToTypeWithCheck19(value, array, "to_a"); if (tmp.isNil()) return context.runtime.newEmptyArray(); } return (RubyArray) tmp; // converters will guarantee it is RubyArray or raise. }
/** rb_ary_take * */ @JRubyMethod(name = "drop") public IRubyObject drop(ThreadContext context, IRubyObject n) { Ruby runtime = context.runtime; long pos = RubyNumeric.num2long(n); if (pos < 0) throw runtime.newArgumentError("attempt to drop negative size"); IRubyObject result = subseq(pos, realLength); return result.isNil() ? runtime.newEmptyArray() : result; }
/** rb_ary_take * */ @JRubyMethod(name = "drop") public IRubyObject drop(ThreadContext context, IRubyObject n) { Ruby runtime = context.runtime; long pos = RubyNumeric.num2long(n); if (pos < 0) throw runtime.newArgumentError("attempt to drop negative size"); IRubyObject result = subseq(pos, realLength); return result.isNil() ? runtime.newEmptyArray() : result; }
/** rb_ary_take * */ @JRubyMethod(name = "drop") public IRubyObject drop(ThreadContext context, IRubyObject n) { Ruby runtime = context.runtime; long pos = RubyNumeric.num2long(n); if (pos < 0) throw runtime.newArgumentError("attempt to drop negative size"); IRubyObject result = subseq(pos, realLength); return result.isNil() ? runtime.newEmptyArray() : result; }