Package org.jruby

Examples of org.jruby.Ruby.newString()


            Ruby runtime = recv.getRuntime();
            ConsoleHolder holder = getHolder(runtime);
            RubyArray histList = runtime.newArray();

            for (Iterator i = holder.history.getHistoryList().iterator(); i.hasNext();) {
                histList.append(runtime.newString((String) i.next()));
            }

            return histList;
        }
View Full Code Here


            if (i < 0) i += holder.history.size();

            try {
                ThreadContext context = runtime.getCurrentContext();

                return runtime.newString((String) holder.history.getHistoryList().get(i)).taint(context);
            } catch (IndexOutOfBoundsException ioobe) {
                throw runtime.newIndexError("invalid history index: " + i);
            }
        }
View Full Code Here

    private RaiseException newRefError(String message) {
        Ruby runtime = getRuntime();
        ThreadContext context = runtime.getCurrentContext();
        RubyException exception =
                (RubyException)runtime.getClass("RefError").newInstance(context,
                new IRubyObject[] {runtime.newString(message)}, Block.NULL_BLOCK);
       
        RaiseException re = new RaiseException(exception);
        return re;
    }
}
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.fastSetInstanceVariable("@__java_ovrd_methods",methodNames);
                } else {
View Full Code Here

                    break;
                }
            } catch (ParserException pe) {
                parser = null;
                RubyKernel.raise(context, runtime.getKernel(),
                    new IRubyObject[] {runtime.getModule("Psych").getConstant("SyntaxError"), runtime.newString(pe.getLocalizedMessage())},
                    Block.NULL_BLOCK);
            } catch (ScannerException se) {
                parser = null;
                StringBuilder message = new StringBuilder("syntax error");
                if (se.getProblemMark() != null) {
View Full Code Here

            ConsoleHolder holder = getHolder(runtime);

            if (holder.history.size() == 0) return runtime.getNil();

            try {
                return runtime.newString(holder.history.remove(0)).taint(runtime.getCurrentContext());
            } catch (IndexOutOfBoundsException ioobe) {
                throw runtime.newIndexError("history shift error");
            }
        }
View Full Code Here

            int i = RubyNumeric.num2int(index);

            if (i < 0) i += holder.history.size();
           
            try {
                return runtime.newString(holder.history.remove(i)).taint(context);
            } catch (IndexOutOfBoundsException ioobe) {
                throw runtime.newIndexError("invalid history index: " + i);
            }
        }
View Full Code Here

            Ruby runtime = recv.getRuntime();
            ThreadContext context = runtime.getCurrentContext();
            ConsoleHolder holder = getHolder(runtime);

            for (Iterator i = holder.history.getHistoryList().iterator(); i.hasNext();) {
                block.yield(context, runtime.newString((String) i.next()).taint(context));
            }
            return recv;
        }
    }
View Full Code Here

            int index = wordIndexOf(buffer);
            if (index != -1) buffer = buffer.substring(index + 1);

            Ruby runtime = procCompletor.getRuntime();
            ThreadContext context = runtime.getCurrentContext();
            IRubyObject result = procCompletor.callMethod(context, "call", runtime.newString(buffer));
            IRubyObject comps = result.callMethod(context, "to_a");
           
            if (comps instanceof List) {
                for (Iterator i = ((List) comps).iterator(); i.hasNext();) {
                    Object obj = i.next();
View Full Code Here

    }

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

        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.getRuntime();
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.