Refine search
public PrintStream getErrorStream() { // FIXME: We can't guarantee this will always be a RubyIO...so the old code here is not safe /*java.io.OutputStream os = ((RubyIO) getGlobalVariables().getService("$stderr")).getOutStream(); if(null != os) { return new PrintStream(os); } else { return new PrintStream(new org.jruby.util.SwallowingOutputStream()); }*/ return new PrintStream(new IOOutputStream(getGlobalVariables().get("$stderr"))); }
@JRubyMethod(name = "chomp!") public IRubyObject chomp_bang19(ThreadContext context) { modifyCheck(); Ruby runtime = context.runtime; if (value.getRealSize() == 0) return context.nil; IRubyObject rsObj = runtime.getGlobalVariables().get("$/"); if (rsObj == runtime.getGlobalVariables().getDefaultSeparator()) return smartChopBangCommon(runtime); return chompBangCommon(runtime, rsObj); }
/** * Prints a warning, unless $VERBOSE is nil. */ public void warn(ID id, String fileName, int lineNumber, String message) { if (!runtime.warningsEnabled()) return; StringBuilder buffer = new StringBuilder(100); buffer.append(fileName).append(':').append(lineNumber + 1).append(' '); buffer.append("warning: ").append(message).append('\n'); IRubyObject errorStream = runtime.getGlobalVariables().get("$stderr"); errorStream.callMethod(runtime.getCurrentContext(), "write", runtime.newString(buffer.toString())); }
@JRubyMethod(name = "chomp!", compat = RUBY1_9) public IRubyObject chomp_bang19(ThreadContext context) { Ruby runtime = context.runtime; if (value.getRealSize() == 0) return runtime.getNil(); IRubyObject rsObj = runtime.getGlobalVariables().get("$/"); if (rsObj == runtime.getGlobalVariables().getDefaultSeparator()) return smartChopBangCommon19(runtime); return chompBangCommon19(runtime, rsObj); }
public PrintStream getErrorStream() { // FIXME: We can't guarantee this will always be a RubyIO...so the old code here is not safe /*java.io.OutputStream os = ((RubyIO) getGlobalVariables().get("$stderr")).getOutStream(); if(null != os) { return new PrintStream(os); } else { return new PrintStream(new org.jruby.util.SwallowingOutputStream()); }*/ return new PrintStream(new IOOutputStream(getGlobalVariables().get("$stderr"))); }
@JRubyMethod(rest = true, module = true, visibility = PRIVATE, reads = LASTLINE) public static IRubyObject print(ThreadContext context, IRubyObject recv, IRubyObject[] args) { RubyIO.print(context, context.runtime.getGlobalVariables().get("$>"), args); return context.nil; }
/** rb_str_each_line * */ @JRubyMethod(name = "each_line") public IRubyObject each_line(ThreadContext context, Block block) { return StringSupport.rbStrEnumerateLines(this, context, "each_line", context.runtime.getGlobalVariables().get("$/"), block, false); }
@Interp @Override public Object retrieve(ThreadContext context, IRubyObject self, StaticScope currScope, DynamicScope currDynScope, Object[] temp) { return context.runtime.getGlobalVariables().get(getId()); }
@Interp @Override public Object retrieve(ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp) { return context.runtime.getGlobalVariables().get(getName()); }
@JRubyMethod(name = "puts", module = true, visibility = PRIVATE) public static IRubyObject puts(ThreadContext context, IRubyObject recv, IRubyObject arg0) { IRubyObject defout = context.runtime.getGlobalVariables().get("$>"); return RubyIO.puts1(context, defout, arg0); }
@JRubyMethod(rest = true, module = true, visibility = PRIVATE, reads = LASTLINE) public static IRubyObject print(ThreadContext context, IRubyObject recv, IRubyObject[] args) { RubyIO.print(context, context.runtime.getGlobalVariables().get("$>"), args); return context.nil; }
@Override public IRubyObject set(IRubyObject value) { if (runtime.getGlobalVariables().get("$!").isNil()) { throw runtime.newArgumentError("$! not set"); } runtime.getGlobalVariables().get("$!").callMethod(value.getRuntime().getCurrentContext(), "set_backtrace", value); return value; } }
@Override public IRubyObject set(IRubyObject value) { if (runtime.getGlobalVariables().get("$!").isNil()) { throw runtime.newArgumentError("$! not set"); } runtime.getGlobalVariables().get("$!").callMethod(value.getRuntime().getCurrentContext(), "set_backtrace", value); return value; } }
public static IRubyObject rbStrEnumerateLines(RubyString str, ThreadContext context, String name, IRubyObject arg, Block block, boolean wantarray) { IRubyObject opts = ArgsUtil.getOptionsArg(context.runtime, arg); if (opts == context.nil) { return rbStrEnumerateLines(str, context, name, arg, context.nil, block, wantarray); } return rbStrEnumerateLines(str, context, name, context.runtime.getGlobalVariables().get("$/"), opts, block, wantarray); }
public static void writeWarningToError(ThreadContext context, RubyString errorString) { Ruby runtime = context.runtime; IRubyObject errorStream = runtime.getGlobalVariables().get("$stderr"); RubyModule warning = runtime.getWarning(); sites(context).write.call(context, warning, errorStream, errorString); }
@JRubyMethod(name = "filename", alias = {"path"}) public static IRubyObject filename(ThreadContext context, IRubyObject recv) { ArgsFileData.getArgsFileData(context.runtime).next_argv(context); return context.runtime.getGlobalVariables().get("$FILENAME"); }
@JRubyMethod(name = "filename", alias = {"path"}) public static IRubyObject filename(ThreadContext context, IRubyObject recv) { ArgsFileData.getArgsFileData(context.runtime).next_argv(context); return context.runtime.getGlobalVariables().get("$FILENAME"); }
private boolean requiresBacktrace(ThreadContext context) { IRubyObject debugMode; // We can only omit backtraces of descendents of Standard error for 'foo rescue nil' return context.exceptionRequiresBacktrace || ((debugMode = context.runtime.getGlobalVariables().get("$DEBUG")) != null && debugMode.isTrue()) || ! context.runtime.getStandardError().isInstance(exception); }
public static IRubyObject rbStrEnumerateLines(RubyString str, ThreadContext context, String name, IRubyObject arg, Block block, boolean wantarray) { IRubyObject opts = ArgsUtil.getOptionsArg(context.runtime, arg); if (opts == context.nil) { return rbStrEnumerateLines(str, context, name, arg, context.nil, block, wantarray); } return rbStrEnumerateLines(str, context, name, context.runtime.getGlobalVariables().get("$/"), opts, block, wantarray); }
@JRubyMethod(module = true, visibility = PRIVATE) public static IRubyObject puts(ThreadContext context, IRubyObject recv, IRubyObject arg0, IRubyObject arg1) { IRubyObject defout = context.runtime.getGlobalVariables().get("$>"); if (recv == defout) { return RubyIO.puts2(context, recv, arg0, arg1); } return sites(context).puts.call(context, defout, defout, arg0, arg1); }