Package org.jruby

Examples of org.jruby.Ruby.newString()


            Ruby r = context.getRuntime();
            InetAddress addr;
            String hostString = hostname.convertToString().toString();
            addr = InetAddress.getByName(hostString);
           
            ret[0] = r.newString(do_not_reverse_lookup(recv).isTrue() ? addr.getHostAddress() : addr.getCanonicalHostName());
            ret[1] = r.newArray();
            ret[3] = r.newString(addr.getHostAddress());
           
            if (addr instanceof Inet4Address) {
                Inet4Address addr4 = (Inet4Address)addr;
View Full Code Here


            String hostString = hostname.convertToString().toString();
            addr = InetAddress.getByName(hostString);
           
            ret[0] = r.newString(do_not_reverse_lookup(recv).isTrue() ? addr.getHostAddress() : addr.getCanonicalHostName());
            ret[1] = r.newArray();
            ret[3] = r.newString(addr.getHostAddress());
           
            if (addr instanceof Inet4Address) {
                Inet4Address addr4 = (Inet4Address)addr;
                ret[2] = r.newFixnum(AF_INET); //AF_INET
            } else if (addr instanceof Inet6Address) {
View Full Code Here

        if (sniffedEncoding == null) return source; // assume UTF-8
        Ruby runtime = context.getRuntime();
        return (RubyString)info.jsonModule.get().
            callMethod(context, "iconv",
                new IRubyObject[] {
                    runtime.newString("utf-8"),
                    runtime.newString(sniffedEncoding),
                    source});
    }

    /**
 
View Full Code Here

        Ruby runtime = context.getRuntime();
        return (RubyString)info.jsonModule.get().
            callMethod(context, "iconv",
                new IRubyObject[] {
                    runtime.newString("utf-8"),
                    runtime.newString(sniffedEncoding),
                    source});
    }

    /**
     * Checks the first four bytes of the given ByteList to infer its encoding,
View Full Code Here

        @JRubyMethod(name = "errors", meta = true)
        public static IRubyObject errors(IRubyObject recv) {
            Ruby runtime = recv.getRuntime();
            RubyArray result = runtime.newArray();
            for (X509Error.ErrorException e : X509Error.getErrors()) {
                result.add(runtime.newString(e.getMessage()));
            }
            return result;
        }

        @JRubyMethod(name = "debug", meta = true)
View Full Code Here

                    synchronized(methods = ancestor.getMethods()) {
                        methodNames = RubyArray.newArrayLight(runtime,methods.size());
                        for (String methodName: methods.keySet()) {
                            if (!EXCLUDE_METHODS.contains(methodName)) {
                                names.add(methodName);
                                methodNames.append(runtime.newString(methodName));
                            }
                        }
                    }
                    ancestor.setInstanceVariable("@__java_ovrd_methods",methodNames);
                } else {
View Full Code Here

        if (bytes == null) {
            throw runtime.newTypeError("wrong argument type " + wrappedObject.getMetaClass() +
                    " (expected byte[])");
        }

        return runtime.newString(new ByteList(bytes, true));
    }
   
    @JRubyMethod(module = true, visibility = Visibility.PRIVATE)
    public static IRubyObject ruby_string_to_bytes(IRubyObject recv, IRubyObject string) {
        Ruby runtime = recv.getRuntime();
View Full Code Here

    }

    @JRubyMethod(name = "open", required = 1, optional = 2, meta = true, compat = RUBY1_8)
    public static IRubyObject open18(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) {
        Ruby runtime = recv.getRuntime();
        IRubyObject io = RuntimeHelpers.invoke(context, runtime.getFile(), "open", args[0], runtime.newString("wb"));
        JZlibRubyGzipWriter gzio = newInstance(recv, argsWithIo(io, args), block);
       
        return RubyGzipFile.wrapBlock(context, gzio, block);
    }
View Full Code Here

    }

    @JRubyMethod(name = "open", required = 1, optional = 3, meta = true, compat = RUBY1_9)
    public static IRubyObject open19(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) {
        Ruby runtime = recv.getRuntime();
        IRubyObject io = RuntimeHelpers.invoke(context, runtime.getFile(), "open", args[0], runtime.newString("wb"));
        JZlibRubyGzipWriter gzio = newInstance(recv, argsWithIo(io, args), block);
       
        return RubyGzipFile.wrapBlock(context, gzio, block);
    }
View Full Code Here

    }

    private static IRubyObject raiseBecauseCritical(ThreadContext context) {
        Ruby runtime = context.runtime;

        return RubyKernel.raise(context, runtime.getKernel(), new IRubyObject[]{runtime.getThreadError(), runtime.newString("timeout within critical section")}, Block.NULL_BLOCK);
    }

    private static IRubyObject raiseTimeoutError(ThreadContext context, RaiseException re) {
        Ruby runtime = context.runtime;
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.