public IRubyObject call(ThreadContext context, IRubyObject[] args) {
return call(context, args, null, Block.NULL_BLOCK);
}
private IRubyObject[] prepareProcArgs(ThreadContext context, IRubyObject[] args) {
Arity arity = block.arity();
// for procs and blocks, single array passed to multi-arg must be spread
if (arity != Arity.ONE_ARGUMENT && arity.required() != 0 &&
(arity.isFixed() || arity != Arity.OPTIONAL) &&
args.length == 1 && args[0].respondsTo("to_ary")) {
args = args[0].convertToArray().toJavaArray();
}
if (arity.isFixed()) {
List<IRubyObject> list = new ArrayList<IRubyObject>(Arrays.asList(args));
int required = arity.required();
if (required > args.length) {
for (int i = args.length; i < required; i++) {
list.add(context.runtime.getNil());
}
args = list.toArray(args);