Examples of newArgumentError()


Examples of org.jruby.Ruby.newArgumentError()

                ip += 4;
                int max = getInt(bytecodes, ip);
                ip += 4;

                if(args.length < min) {
                    throw runtime.newArgumentError("wrong # of arguments(" + args.length + " for " + min + ")");
                } else if(max>0 && args.length>max) {
                    throw runtime.newArgumentError("wrong # of arguments(" + args.length + " for " + max + ")");
                }
                break;
            }
View Full Code Here

Examples of org.jruby.Ruby.newArgumentError()

                ip += 4;

                if(args.length < min) {
                    throw runtime.newArgumentError("wrong # of arguments(" + args.length + " for " + min + ")");
                } else if(max>0 && args.length>max) {
                    throw runtime.newArgumentError("wrong # of arguments(" + args.length + " for " + max + ")");
                }
                break;
            }
            case RubiniusInstructions.META_PUSH_0: {
                stack[++stackTop] = RubyFixnum.zero(runtime);
View Full Code Here

Examples of org.jruby.Ruby.newArgumentError()

    @JRubyMethod
    public static IRubyObject create_jar(ThreadContext context, IRubyObject recv, IRubyObject jar_path, IRubyObject entries) {
        final Ruby runtime = recv.getRuntime();

        if (!(entries instanceof RubyHash)) {
            throw runtime.newArgumentError("expected a hash for the second argument");
        }

        RubyHash hash = (RubyHash) entries;
        try {
            FileOutputStream file = newFile(jar_path);
View Full Code Here

Examples of org.jruby.Ruby.newArgumentError()

                IRubyObject vSelf, IRubyObject vHash) {
            Ruby runtime = context.getRuntime();
            RubyHash o = vHash.convertToHash();
            IRubyObject rawData = o.fastARef(runtime.newString("raw"));
            if (rawData == null) {
                throw runtime.newArgumentError("\"raw\" value not defined "
                                               + "for encoded String");
            }
            RubyArray ary = Utils.ensureArray(rawData);
            byte[] bytes = new byte[ary.getLength()];
            for (int i = 0, t = ary.getLength(); i < t; i++) {
View Full Code Here

Examples of org.jruby.Ruby.newArgumentError()

        @JRubyMethod(rest = true, visibility = PRIVATE)
        public IRubyObject initialize(ThreadContext context, final IRubyObject[] args, Block block) {
            final Ruby runtime = context.getRuntime();

            if (block == null || !block.isGiven()) {
                throw runtime.newArgumentError("tried to create Proc object without a block");
            }

            this.block = block;
            this.parent = context.getThread();
            this.result = runtime.getNil();
View Full Code Here

Examples of org.jruby.Ruby.newArgumentError()

        @JRubyMethod(name = "wait", required = 1, optional = 1)
        public IRubyObject wait_ruby(ThreadContext context, IRubyObject args[]) {
            Ruby runtime = context.getRuntime();
            if ( args.length < 1 ) {
                throw runtime.newArgumentError(args.length, 1);
            }
            if ( args.length > 2 ) {
                throw runtime.newArgumentError(args.length, 2);
            }
View Full Code Here

Examples of org.jruby.Ruby.newArgumentError()

            Ruby runtime = context.getRuntime();
            if ( args.length < 1 ) {
                throw runtime.newArgumentError(args.length, 1);
            }
            if ( args.length > 2 ) {
                throw runtime.newArgumentError(args.length, 2);
            }

            if (!( args[0] instanceof Mutex )) {
                throw context.getRuntime().newTypeError(args[0], runtime.fastGetClass("Mutex"));
            }
View Full Code Here

Examples of org.jruby.Ruby.newArgumentError()

            Double timeout = null;
            if ( args.length > 1 && !args[1].isNil() ) {
                timeout = args[1].convertToFloat().getDoubleValue();
                if (timeout < 0) {
                    throw runtime.newArgumentError("time interval must be positive");
                }
            }

            if (Thread.interrupted()) {
                throw runtime.newConcurrencyError("thread interrupted");
View Full Code Here

Examples of org.jruby.Ruby.newArgumentError()

        String host, port;
        if (arg0 instanceof RubyArray) {
            List list = ((RubyArray)arg0).getList();
            int len = list.size();
            if (len < 3 || len > 4) {
                throw runtime.newArgumentError("array size should be 3 or 4, "+len+" given");
            }
            // if array has 4 elements, third element is ignored
            host = list.size() == 3 ? list.get(2).toString() : list.get(3).toString();
            port = list.get(1).toString();
        } else if (arg0 instanceof RubyString) {
View Full Code Here

Examples of org.jruby.Ruby.newArgumentError()

                IRubyObject obj = unpack_sockaddr_in(context, recv, arg0);
                if (obj instanceof RubyArray) {
                    List list = ((RubyArray)obj).getList();
                    int len = list.size();
                    if (len != 2) {
                        throw runtime.newArgumentError("invalid address representation");
                    }
                    host = list.get(1).toString();
                    port = list.get(0).toString();
                }
                else {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.