Examples of newString()


Examples of org.jruby.Ruby.newString()

        @JRubyMethod(required=1)
        public static IRubyObject json_create(ThreadContext context,
                IRubyObject vSelf, IRubyObject vHash) {
            Ruby runtime = context.getRuntime();
            RubyHash o = vHash.convertToHash();
            IRubyObject rawData = o.fastARef(runtime.newString("raw"));
            if (rawData == null) {
                throw runtime.newArgumentError("\"raw\" value not defined "
                                               + "for encoded String");
            }
            RubyArray ary = Utils.ensureArray(rawData);
View Full Code Here

Examples of org.jruby.Ruby.newString()

                    bytes[i] = (byte)RubyNumeric.fix2long(element);
                } else {
                    throw runtime.newTypeError(element, runtime.getFixnum());
                }
            }
            return runtime.newString(new ByteList(bytes, false));
        }
    }

    public static class RbTrue {
        @JRubyMethod(rest=true)
View Full Code Here

Examples of org.jruby.Ruby.newString()

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

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

    public static String jrubyScript() {
        return SafePropertyAccessor.getProperty("jruby.script", "jruby").replace('\\', '/');
    }
View Full Code Here

Examples of org.jruby.Ruby.newString()

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

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

    public static String jrubyScript() {
        return SafePropertyAccessor.getProperty("jruby.script", "jruby").replace('\\', '/');
    }
View Full Code Here

Examples of org.jruby.Ruby.newString()

    @JRubyMethod(name = "ruby", module = true, compat = CompatVersion.RUBY1_9)
    public static IRubyObject ruby(ThreadContext context, IRubyObject recv) {
        Ruby runtime = context.getRuntime();
        RubyHash configHash = (RubyHash) runtime.getModule("Config").getConstant("CONFIG");

        IRubyObject bindir            = configHash.op_aref(context, runtime.newString("bindir"));
        IRubyObject ruby_install_name = configHash.op_aref(context, runtime.newString("ruby_install_name"));
        IRubyObject exeext            = configHash.op_aref(context, runtime.newString("EXEEXT"));

        return RuntimeHelpers.invoke(context, runtime.getClass("File"), "join", bindir, ruby_install_name.callMethod(context, "+", exeext));
    }
View Full Code Here

Examples of org.jruby.Ruby.newString()

    public static IRubyObject ruby(ThreadContext context, IRubyObject recv) {
        Ruby runtime = context.getRuntime();
        RubyHash configHash = (RubyHash) runtime.getModule("Config").getConstant("CONFIG");

        IRubyObject bindir            = configHash.op_aref(context, runtime.newString("bindir"));
        IRubyObject ruby_install_name = configHash.op_aref(context, runtime.newString("ruby_install_name"));
        IRubyObject exeext            = configHash.op_aref(context, runtime.newString("EXEEXT"));

        return RuntimeHelpers.invoke(context, runtime.getClass("File"), "join", bindir, ruby_install_name.callMethod(context, "+", exeext));
    }
View Full Code Here

Examples of org.jruby.Ruby.newString()

        Ruby runtime = context.getRuntime();
        RubyHash configHash = (RubyHash) runtime.getModule("Config").getConstant("CONFIG");

        IRubyObject bindir            = configHash.op_aref(context, runtime.newString("bindir"));
        IRubyObject ruby_install_name = configHash.op_aref(context, runtime.newString("ruby_install_name"));
        IRubyObject exeext            = configHash.op_aref(context, runtime.newString("EXEEXT"));

        return RuntimeHelpers.invoke(context, runtime.getClass("File"), "join", bindir, ruby_install_name.callMethod(context, "+", exeext));
    }

    private static String getRubyEnv(RubyHash envHash, String var, String default_value) {
View Full Code Here

Examples of org.jruby.Ruby.newString()

    public void test() {
        Ruby runtime = Ruby.newInstance();
        // This is now needed, since module Java
        // isn't in by default
        runtime.getModule("Kernel").callMethod(runtime.getCurrentContext(),"require",runtime.newString("java"));
        JavaClass javaClass = JavaClass.get(runtime, String.class);
        assertSame(javaClass, JavaClass.get(runtime, String.class));
    }
}
View Full Code Here

Examples of org.jruby.Ruby.newString()

        RubyInstanceConfig config = new RubyInstanceConfig() {{
            setInput(System.in); setOutput(System.out); setError(new PrintStream(err)); setObjectSpaceEnabled(false);
            setTraceType(TraceType.traceTypeFor("mri"));
        }};
        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.<IRubyObject>asList(lines));
View Full Code Here

Examples of org.jruby.Ruby.newString()

        RubyInstanceConfig config = new RubyInstanceConfig() {{
            setInput(System.in); setOutput(System.out); setError(new PrintStream(err)); setObjectSpaceEnabled(false);
            setTraceType(TraceType.traceTypeFor("mri"));
        }};
        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
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.