Refine search
@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 * */ public IRubyObject each_line(ThreadContext context, Block block) { return each_lineCommon(context, context.runtime.getGlobalVariables().get("$/"), block); }
private Variables(Ruby runtime) { super(runtime); //we have to copy variables from the origin one to this GlobalVariables vars = runtime.getGlobalVariables(); for (Iterator it = vars.getNames().iterator(); it.hasNext();) { final String nm = (String) it.next(); set(nm, vars.get(nm)); } }
@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); }
@JRubyMethod(name = "global_variables", module = true, visibility = PRIVATE, compat = RUBY1_9) public static RubyArray global_variables19(ThreadContext context, IRubyObject recv) { Ruby runtime = context.runtime; RubyArray globalVariables = runtime.newArray(); for (String globalVariableName : runtime.getGlobalVariables().getNames()) { globalVariables.append(runtime.newSymbol(globalVariableName)); } return globalVariables; }
/** 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); }
@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); }
/** rb_str_each_line * */ public IRubyObject each_line(ThreadContext context, Block block) { return each_lineCommon(context, context.runtime.getGlobalVariables().get("$/"), block); }
/** Returns an Array with the names of all global variables. * */ @JRubyMethod(name = "global_variables", module = true, visibility = PRIVATE) public static RubyArray global_variables(ThreadContext context, IRubyObject recv) { Ruby runtime = context.runtime; RubyArray globalVariables = runtime.newArray(); for (String globalVariableName : runtime.getGlobalVariables().getNames()) { globalVariables.append(runtime.newString(globalVariableName)); } return globalVariables; }
@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(module = true, visibility = PRIVATE) public static IRubyObject warn(ThreadContext context, IRubyObject recv, IRubyObject message) { Ruby runtime = context.runtime; if (runtime.warningsEnabled()) { IRubyObject out = runtime.getGlobalVariables().get("$stderr"); Helpers.invoke(context, out, "write", message); Helpers.invoke(context, out, "write", runtime.getGlobalVariables().getDefaultSeparator()); } return runtime.getNil(); }
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(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; }
@JRubyMethod(module = true, visibility = PRIVATE) public static IRubyObject warn(ThreadContext context, IRubyObject recv, IRubyObject message) { Ruby runtime = context.runtime; if (runtime.warningsEnabled()) { IRubyObject out = runtime.getGlobalVariables().get("$stderr"); Helpers.invoke(context, out, "write", message); Helpers.invoke(context, out, "write", runtime.getGlobalVariables().getDefaultSeparator()); } return runtime.getNil(); }
@Deprecated @Override public void warn(ID id, String fileName, int lineNumber, String message, Object... data) { if (!runtime.warningsEnabled()) return; // TODO make an assert here StringBuilder buffer = new StringBuilder(100); buffer.append(fileName).append(':').append(lineNumber).append(' '); buffer.append("warning: ").append(message).append('\n'); IRubyObject errorStream = runtime.getGlobalVariables().get("$stderr"); errorStream.callMethod(runtime.getCurrentContext(), "write", runtime.newString(buffer.toString())); }
/** rb_f_putc */ @JRubyMethod(name = "putc", required = 1, module = true, visibility = PRIVATE) public static IRubyObject putc(ThreadContext context, IRubyObject recv, IRubyObject ch) { IRubyObject defout = context.runtime.getGlobalVariables().get("$>"); return RubyIO.putc(context, defout, ch); }
@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 = "puts", module = true, visibility = PRIVATE) public static IRubyObject puts(ThreadContext context, IRubyObject recv) { IRubyObject defout = context.runtime.getGlobalVariables().get("$>"); return RubyIO.puts0(context, defout); }
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"))); }