Package org.jruby

Examples of org.jruby.Ruby.newArgumentError()


        int bits = RubyNumeric.num2int(args[0]);
        boolean safe = argc > 1 ? args[1] != runtime.getFalse() : true;
        BigInteger add = argc > 2 ? getBigInteger(args[2]) : null;
        BigInteger rem = argc > 3 ? getBigInteger(args[3]) : null;
        if (bits < 3) {
            if (safe) throw runtime.newArgumentError("bits < 3");
            if (bits < 2) throw runtime.newArgumentError("bits < 2");
        }
        return newBN(runtime, generatePrime(bits, safe, add, rem));
    }
   
View Full Code Here


        boolean safe = argc > 1 ? args[1] != runtime.getFalse() : true;
        BigInteger add = argc > 2 ? getBigInteger(args[2]) : null;
        BigInteger rem = argc > 3 ? getBigInteger(args[3]) : null;
        if (bits < 3) {
            if (safe) throw runtime.newArgumentError("bits < 3");
            if (bits < 2) throw runtime.newArgumentError("bits < 2");
        }
        return newBN(runtime, generatePrime(bits, safe, add, rem));
    }
   
    public static BigInteger generatePrime(int bits, boolean safe, BigInteger add, BigInteger rem) {
View Full Code Here

    @JRubyMethod(rest = true)
    public static IRubyObject impl(ThreadContext context, IRubyObject self, IRubyObject[] args, final Block implBlock) {
        Ruby runtime = context.runtime;

        if (!implBlock.isGiven()) throw runtime.newArgumentError("block required to call #impl on a Java interface");

        final RubyArray methodNames = (args.length > 0) ? runtime.newArray(args) : null;

        RubyClass implClass = RubyClass.newClass(runtime, runtime.getObject());
        implClass.include(new IRubyObject[] {self});
View Full Code Here

       
        @JRubyMethod(name = "digest", required = 1, rest = true, meta = true)
        public static IRubyObject s_digest(ThreadContext ctx, IRubyObject recv, IRubyObject[] args, Block unusedBlock) {
            Ruby runtime = recv.getRuntime();
            if (args.length < 1) {
                throw runtime.newArgumentError("no data given");
            }
            RubyString str = args[0].convertToString();
            IRubyObject[] newArgs = new IRubyObject[args.length - 1];
            System.arraycopy(args, 1, newArgs, 0, args.length - 1);
            IRubyObject obj = ((RubyClass)recv).newInstance(ctx, newArgs, Block.NULL_BLOCK);
View Full Code Here

   
    @JRubyMethod(meta=true, required=2, rest=true)
    public static IRubyObject q(ThreadContext context, IRubyObject klazz, IRubyObject[] args) {
        Ruby runtime = context.getRuntime();
        if (args.length < 2) {
            throw runtime.newArgumentError("Wrong number of arguments");
        }
        Object query = null;
        if (args[0] instanceof RubyArray) {
            try {
                query = DiametricUtils.fromRubyArray(context, (RubyArray)args[0]);
View Full Code Here

            }
        } else if (args[0] instanceof RubyString) {
            query = DiametricUtils.rubyStringToJava(args[0]);
        }
        if (query == null) {
            throw runtime.newArgumentError("The first arg should be a query string or array");
        }
        //System.out.println("query: " + query.toString());
        Database database = DiametricPeer.getDatabase(args[1]);
        if (database == null) {
            throw runtime.newArgumentError("The second arg should be a database.");
View Full Code Here

            throw runtime.newArgumentError("The first arg should be a query string or array");
        }
        //System.out.println("query: " + query.toString());
        Database database = DiametricPeer.getDatabase(args[1]);
        if (database == null) {
            throw runtime.newArgumentError("The second arg should be a database.");
        }

        Collection<List<Object>> results = null;
        try {
            switch (args.length) {
View Full Code Here

        if ((arg instanceof DiametricObject) && (((DiametricObject)arg).to_java(context) instanceof RubyFixnum)) {
            dbid = ((DiametricObject)arg).toJava();
        } else if (arg instanceof RubyFixnum) {
            dbid = ((RubyFixnum)arg).toJava(Long.class);
        } else {
            throw runtime.newArgumentError("Argument should be dbid");
        }
        if (saved_connection == null) throw runtime.newRuntimeError("Connection is not established");
        try {
            Object database = DiametricService.getFn("datomic.api", "db").invoke(saved_connection.toJava());
            Object entity = DiametricService.getFn("datomic.api", "entity").invoke(database, dbid);
View Full Code Here

                return array;
            } catch (Throwable t) {
                throw runtime.newRuntimeError("Datomic Error: " + t.getMessage());
            }
        } else {
            throw runtime.newArgumentError("Arguments should be 'database, dbid, query_string'");
        }
    }

    @JRubyMethod(meta=true)
    public static IRubyObject get_set(ThreadContext context, IRubyObject klazz) {
View Full Code Here

            Passwd pwd = posix.getpwuid(uid);
            if(pwd == null) {
                if (Platform.IS_WINDOWS) {  // MRI behavior
                    return recv.getRuntime().getNil();
                }
                throw runtime.newArgumentError("can't find user for " + uid);
            }
            return setupPasswd(runtime, pwd);
        } catch (RaiseException re) {
            if (runtime.getNotImplementedError().isInstance(re.getException())) {
                return runtime.getNil();
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.