Package org.jruby

Examples of org.jruby.Ruby.newArray()


                list.add(ele);
            }
        } catch (GeneralSecurityException gse) {
            throw newSSLError(getRuntime(), gse.getMessage());
        }
        return rt.newArray(list);
    }

    @JRubyMethod(name = "ciphers=")
    public IRubyObject set_ciphers(IRubyObject val) {
        if (val.isNil()) {
View Full Code Here


        try {
            InetAddress addr = InetAddress.getByName(hostString);
           
            ret[0] = runtime.newString(do_not_reverse_lookup(context, recv).isTrue() ? addr.getHostAddress() : addr.getCanonicalHostName());
            ret[1] = runtime.newArray();

            if (addr instanceof Inet4Address) {
                ret[2] = runtime.newFixnum(AF_INET);
            } else if (addr instanceof Inet6Address) {
                ret[2] = runtime.newFixnum(AF_INET6);
View Full Code Here

                self = this;
            } else {
                throw runtime.newTypeError("Don't know how to coerce");
            }
        }
        return runtime.newArray(other, self);
    }
   
    @JRubyMethod(name="zero?")
    public IRubyObject bn_is_zero() {
        return getRuntime().newBoolean(value.equals(BigInteger.ZERO));
View Full Code Here

    @JRubyMethod(name="/")
    public IRubyObject bn_div(IRubyObject other) {
        Ruby runtime = getRuntime();
        try {
            BigInteger[] result = value.divideAndRemainder(getBigInteger(other));
            return runtime.newArray(newBN(runtime, result[0]), newBN(runtime, result[1]));
        } catch (ArithmeticException e) {
            throw runtime.newZeroDivisionError();
        }
    }
   
View Full Code Here

    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});

        IRubyObject implObject = implClass.callMethod(context, "new");
View Full Code Here

    @JRubyMethod
    public IRubyObject addr(ThreadContext context) {
        Ruby runtime = context.runtime;

        return runtime.newArray(
                runtime.newString("AF_UNIX"),
                RubyString.newEmptyString(runtime));
    }

    @JRubyMethod
View Full Code Here

    @JRubyMethod
    public IRubyObject peeraddr(ThreadContext context) {
        Ruby runtime = context.runtime;

        return runtime.newArray(
                runtime.newString("AF_UNIX"),
                runtime.newString(fpath));
    }

    @JRubyMethod(name = "recvfrom", required = 1, optional = 1)
View Full Code Here

            flags = 0;
        } else {
            flags = RubyNumeric.fix2int(_flags);
        }

        return runtime.newArray(
                recv(context, _length),
                peeraddr(context));
    }

    @JRubyMethod(notImplemented = true)
View Full Code Here

            RubyUNIXSocket sock2 = (RubyUNIXSocket)(RuntimeHelpers.invoke(context, runtime.getClass("UNIXSocket"), "allocate"));
            sock2.channel = sp[1];
            sock2.fpath = "";
            sock2.init_sock(runtime);

            return runtime.newArray(sock, sock2);

        } catch (IOException ioe) {
            throw runtime.newIOErrorFromException(ioe);

        }
View Full Code Here

                IRubyObject ruby_next = DiametricUtils.convertJavaToRuby(context, itr.next());
                IRubyObject block_result = block.yield(context, ruby_next);
                IRubyObject value = hash_result.callMethod(context, "[]", block_result);
                if (value.isNil()) {
                    // new key
                    IRubyObject[] args = new IRubyObject[]{block_result, runtime.newArray()};
                    value = hash_result.callMethod(context, "[]=", args);
                }
                value.callMethod(context, "<<", ruby_next);
            }
            return hash_result;
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.