org.jruby.Ruby.getGlobalVariables()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(8.2k)|赞(0)|评价(0)|浏览(109)

本文整理了Java中org.jruby.Ruby.getGlobalVariables方法的一些代码示例,展示了Ruby.getGlobalVariables的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ruby.getGlobalVariables方法的具体详情如下:
包路径:org.jruby.Ruby
类名称:Ruby
方法名:getGlobalVariables

Ruby.getGlobalVariables介绍

暂无

代码示例

代码示例来源:origin: org.jruby/jruby-complete

@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;
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

/** rb_str_each_line
 *
 */
public IRubyObject each_line(ThreadContext context, Block block) {
  return each_lineCommon(context, context.runtime.getGlobalVariables().get("$/"), block);
}

代码示例来源:origin: org.zkoss.zk/zk

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));
  }
}

代码示例来源:origin: org.jruby/jruby-complete

@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);
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

@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;
}

代码示例来源:origin: org.jruby/jruby-complete

/** 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);
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

@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);
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

/** rb_str_each_line
 *
 */
public IRubyObject each_line(ThreadContext context, Block block) {
  return each_lineCommon(context, context.runtime.getGlobalVariables().get("$/"), block);
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

/** 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;
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

@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);
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

@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();
}

代码示例来源:origin: org.jruby/jruby-complete

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")));
}

代码示例来源:origin: org.jruby/jruby-core

@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;
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

@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();
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

@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()));
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

/** 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);
}

代码示例来源:origin: org.jruby/jruby-core

@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);
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

/**
 * 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()));
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

@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);
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

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")));
}

相关文章

微信公众号

最新文章

更多

Ruby类方法