/** do_coerce * */ protected final RubyArray doCoerce(ThreadContext context, IRubyObject other, boolean err) { if (!sites(context).respond_to_coerce.respondsTo(context, other, other)) { if (err) { coerceFailed(context, other); } return null; } final IRubyObject $ex = context.getErrorInfo(); final IRubyObject result; result = coerceBody(context, other); return coerceResult(context.runtime, result, err); }
/** do_coerce * */ protected final RubyArray doCoerce(ThreadContext context, IRubyObject other, boolean err) { if (!sites(context).respond_to_coerce.respondsTo(context, other, other)) { if (err) { coerceFailed(context, other); } return null; } final IRubyObject $ex = context.getErrorInfo(); final IRubyObject result; result = coerceBody(context, other); return coerceResult(context.runtime, result, err); }
/** do_coerce * */ protected final RubyArray doCoerce(ThreadContext context, IRubyObject other, boolean err) { IRubyObject result; try { result = coerceBody(context, other); } catch (RaiseException e) { if (err) { throw getRuntime().newTypeError( other.getMetaClass().getName() + " can't be coerced into " + getMetaClass().getName()); } return null; } if (!(result instanceof RubyArray) || ((RubyArray) result).getLength() != 2) { if (err) { throw getRuntime().newTypeError("coerce must return [x, y]"); } return null; } return (RubyArray) result; }
/** do_coerce * */ protected final RubyArray doCoerce(ThreadContext context, IRubyObject other, boolean err) { IRubyObject result; try { result = coerceBody(context, other); } catch (RaiseException e) { if (err) { throw getRuntime().newTypeError( other.getMetaClass().getName() + " can't be coerced into " + getMetaClass().getName()); } return null; } if (!(result instanceof RubyArray) || ((RubyArray) result).getLength() != 2) { if (err) { throw getRuntime().newTypeError("coerce must return [x, y]"); } return null; } return (RubyArray) result; }