Package org.jruby

Examples of org.jruby.RubyClass.newInstance()


    @JRubyMethod(required = 1, optional = 1, meta = true, compat = CompatVersion.RUBY1_8)
    public static IRubyObject open(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) {
        Ruby runtime = context.runtime;
        RubyClass klass = (RubyClass) recv;
        Tempfile tempfile = (Tempfile) klass.newInstance(context, args, block);

        if (block.isGiven()) {
            try {
                block.yield(context, tempfile);
            } finally {
View Full Code Here


    @JRubyMethod(required = 1, optional = 1, meta = true, compat = CompatVersion.RUBY1_9)
    public static IRubyObject open19(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) {
        Ruby runtime = context.runtime;
        RubyClass klass = (RubyClass) recv;
        Tempfile tempfile = (Tempfile) klass.newInstance(context, args, block);

        if (block.isGiven()) {
            try {
                return block.yield(context, tempfile);
            } finally {
View Full Code Here

   
    private static RubyIconv newIconv(ThreadContext context, IRubyObject recv,
            IRubyObject to, IRubyObject from) {
        RubyClass klazz = (RubyClass)recv;

        return (RubyIconv) klazz.newInstance(
                context, new IRubyObject[] {to, from}, Block.NULL_BLOCK);
    }

    @JRubyMethod
    public IRubyObject initialize(IRubyObject arg1, IRubyObject arg2, Block unusedBlock) {
View Full Code Here

        IRubyObject exception;

        runtime = context.runtime;
        se = (RubyClass)runtime.getModule("Psych").getConstant("SyntaxError");

        exception = se.newInstance(context,
                new IRubyObject[] {
                    rbPath,
                    runtime.newFixnum(0),
                    runtime.newFixnum(0),
                    runtime.newFixnum(re.getPosition()),
View Full Code Here

        runtime = context.runtime;
        se = (RubyClass)runtime.getModule("Psych").getConstant("SyntaxError");

        mark = mye.getProblemMark();

        exception = se.newInstance(context,
                new IRubyObject[] {
                    rbPath,
                    runtime.newFixnum(mark.getLine() + 1),
                    runtime.newFixnum(mark.getColumn() + 1),
                    runtime.newFixnum(mark.getIndex()),
View Full Code Here

            // if the given parameter is a Generator::State, return itself
            if (klass.isInstance(opts)) return (GeneratorState)opts;

            // if the given parameter is a Hash, pass it to the instantiator
            if (context.getRuntime().getHash().isInstance(opts)) {
                return (GeneratorState)klass.newInstance(context,
                        new IRubyObject[] {opts}, Block.NULL_BLOCK);
            }
        }

        // for other values, return the safe prototype
View Full Code Here

                    WindowMonitor.getInstance(), MarathonAppType.JAVA);
            Ruby interpreter = script.getInterpreter();
            assertTrue("Collector not defined", interpreter.isClassDefined("Collector"));
            RubyClass collectorClass = interpreter.getClass("Collector");
            IRubyObject presult = JavaEmbedUtils.javaToRuby(interpreter, result);
            IRubyObject collector = collectorClass.newInstance(interpreter.getCurrentContext(), new IRubyObject[0], null);
            IRubyObject rubyObject = interpreter.evalScriptlet("proc { my_function }");
            try {
                collector.callMethod(interpreter.getCurrentContext(), "callprotected", new IRubyObject[] { rubyObject, presult });
            } catch (Throwable t) {
View Full Code Here

                WindowMonitor.getInstance(), MarathonAppType.JAVA);
        Ruby interpreter = script.getInterpreter();
        assertTrue("Collector not defined", interpreter.isClassDefined("Collector"));
        RubyClass collectorClass = interpreter.getClass("Collector");
        IRubyObject presult = JavaEmbedUtils.javaToRuby(interpreter, result);
        IRubyObject collector = collectorClass.newInstance(interpreter.getCurrentContext(), new IRubyObject[0], null);
        IRubyObject rubyObject = interpreter.evalScriptlet("proc { my_function }");
        try {
            collector.callMethod(interpreter.getCurrentContext(), "callprotected", new IRubyObject[] { rubyObject, presult });
        } catch (Throwable t) {
View Full Code Here

    }

    @JRubyMethod(required = 1, optional = 1, meta = true)
    public static IRubyObject open19(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) {
        RubyClass klass = (RubyClass) recv;
        Tempfile tempfile = (Tempfile) klass.newInstance(context, args, block);

        if (block.isGiven()) {
            try {
                return block.yield(context, tempfile);
            } finally {
View Full Code Here

        Runnable timeoutRunnable = new Runnable() {
            public void run() {
                if (latch.compareAndSet(false, true)) {
                    if (currentThread.isAlive()) {
                        RubyClass anonException = (RubyClass)runtime.getClassFromPath("Timeout::AnonymousException");
                        IRubyObject anonExceptionObj = anonException.newInstance(runtime.getCurrentContext(), runtime.newString("execution expired"), Block.NULL_BLOCK);
                        anonExceptionObj.getInternalVariables().setInternalVariable("__identifier__", id);
                        currentThread.raise(anonExceptionObj);
                    }
                }
            }
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.