Examples of newString()


Examples of org.jruby.Ruby.newString()

        configModule.defineConstant("MAKEFILE_CONFIG", mkmfHash);
    }

    private static void setConfig(RubyHash mkmfHash, String key, String value) {
        Ruby runtime = mkmfHash.getRuntime();
        mkmfHash.op_aset(runtime.getCurrentContext(), runtime.newString(key), runtime.newString(value));
    }

    public static String jrubyScript() {
        return System.getProperty("jruby.script", Platform.IS_WINDOWS ? "jruby.bat" : "jruby").replace('\\', '/');
    }
View Full Code Here

Examples of org.jruby.Ruby.newString()

               
                for (int i = 0; i < bytecodes[ip].l_op0; i++) {
                    concatter.append(pop().toString());
                }
               
                push(runtime.newString(concatter.toString()));
                break;
            }
            case YARVInstructions.TOSTRING:
                IRubyObject top = peek();
                if (!(top instanceof RubyString)) {
View Full Code Here

Examples of org.jruby.Ruby.newString()

                int bytesRead = -1;
                while ((bytesRead = entryStream.read(buf)) != -1) {
                    blist.append(buf, 0, bytesRead);
                }
                IRubyObject stringio = runtime.getModule("StringIO");
                return stringio.callMethod(context, "new", runtime.newString(blist));
            } finally {
                close(entryStream);
            }
        } catch (IOException e) {
            if (runtime.isDebug()) {
View Full Code Here

Examples of org.jruby.Ruby.newString()

        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

Examples of org.jruby.Ruby.newString()

        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

Examples of org.jruby.Ruby.newString()

        out.close();

        String filePath = f.getAbsolutePath();
        Ruby runtime = Ruby.newInstance();
        initRuby(runtime);
        RubyKernel.require(runtime.getTopSelf(), runtime.newString(filePath), null);
        f.delete();
        return runtime;
    }

    // Is there something built into JRuby to do this?
View Full Code Here

Examples of org.jruby.Ruby.newString()

        final ByteArrayOutputStream err = new ByteArrayOutputStream();
        RubyInstanceConfig config = new RubyInstanceConfig() {{
            setInput(System.in); setOutput(System.out); setError(new PrintStream(err)); setObjectSpaceEnabled(false);
        }};
        Ruby ruby = Ruby.newInstance(config);
        RubyException exception = (RubyException)runtime.getClass("NameError").newInstance(ruby.getCurrentContext(), new IRubyObject[]{ruby.newString("A message")},  Block.NULL_BLOCK);
        RubyString[] lines = new RubyString[]{
            RubyString.newString(ruby, "Line 1"),
            RubyString.newString(ruby, "Line 2"),
        };
        RubyArray backtrace = RubyArray.newArray(ruby, Arrays.asList(lines));
View Full Code Here

Examples of org.jruby.Ruby.newString()

        final ByteArrayOutputStream err = new ByteArrayOutputStream();
        RubyInstanceConfig config = new RubyInstanceConfig() {{
            setInput(System.in); setOutput(System.out); setError(new PrintStream(err)); setObjectSpaceEnabled(false);
        }};
        Ruby ruby = Ruby.newInstance(config);
        RubyException exception = (RubyException)runtime.getClass("NameError").newInstance(ruby.getCurrentContext(), new IRubyObject[]{ruby.newString("A message")},  Block.NULL_BLOCK);
        ruby.printError(exception);
        //        assertEquals(":[0,0]:[0,7]: A message (NameError)\n", err.toString());
    }
}
View Full Code Here

Examples of org.jruby.Ruby.newString()

        synchronized (encodings) {
            WeakReference<RubyEncoding> encoding = encodings.get(name);
            if (encoding == null) {
                Ruby runtime = context.getRuntime();
                encoding = new WeakReference<RubyEncoding>((RubyEncoding)RubyEncoding.find(context,
                        runtime.getEncoding(), runtime.newString(name)));
                encodings.put(name, encoding);
            }
            return encoding.get();
        }
    }
View Full Code Here

Examples of org.jruby.Ruby.newString()

            RubyArray array = runtime.newArray(bl.length());
            for (int i = bl.begin(), t = bl.begin() + bl.length(); i < t; i++) {
                array.store(i, runtime.newFixnum(uBytes[i] & 0xff));
            }

            result.op_aset(context, runtime.newString("raw"), array);
            return result;
        }

        @JRubyMethod(required=1, module=true)
        public static IRubyObject included(ThreadContext context,
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.