Package org.jruby

Examples of org.jruby.Ruby.newArray()


        @JRubyMethod(name = "to_a")
        public static IRubyObject s_hist_to_a(IRubyObject recv) {
            Ruby runtime = recv.getRuntime();
            ConsoleHolder holder = getHolder(runtime);
            RubyArray histList = runtime.newArray();

            ListIterator<History.Entry> historyIterator = holder.history.entries();
            while (historyIterator.hasNext()) {
                History.Entry nextEntry = historyIterator.next();
                histList.append(runtime.newString(nextEntry.value().toString()));
View Full Code Here


            ReceiveTuple tuple = doReceiveNonblockTuple(runtime, length);

            IRubyObject addressArray = addrFor(context, tuple.sender, false);

            return runtime.newArray(tuple.result, addressArray);

        } catch (UnknownHostException e) {
            throw SocketUtils.sockerr(runtime, "recvfrom: name or service not known");

        } catch (PortUnreachableException e) {
View Full Code Here

            ReceiveTuple tuple = doReceiveTuple(runtime, length);

            IRubyObject addressArray = addrFor(context, tuple.sender, false);

            return runtime.newArray(tuple.result, addressArray);

        } catch (UnknownHostException e) {
            throw SocketUtils.sockerr(runtime, "recvfrom: name or service not known");

        } catch (PortUnreachableException e) {
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(openFile.getPath()));
    }

    @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

            sock.init_sock(runtime, sp[0], "");

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

            return runtime.newArray(sock, sock2);

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

        }
View Full Code Here

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

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

    @JRubyMethod
View Full Code Here

    }

    @JRubyMethod
    public RubyArray declared_classes() {
        Ruby runtime = getRuntime();
        RubyArray result = runtime.newArray();
        Class<?> javaClass = javaClass();
        try {
            Class<?>[] classes = javaClass.getDeclaredClasses();
            for (int i = 0; i < classes.length; i++) {
                if (Modifier.isPublic(classes[i].getModifiers())) {
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

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.