本文整理了Java中org.jruby.Ruby.getIO
方法的一些代码示例,展示了Ruby.getIO
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ruby.getIO
方法的具体详情如下:
包路径:org.jruby.Ruby
类名称:Ruby
方法名:getIO
暂无
代码示例来源:origin: org.jruby/jruby-complete
@Deprecated
public static IRubyObject ioOpen(ThreadContext context, IRubyObject filename, IRubyObject vmode, IRubyObject vperm, IRubyObject opt) {
return ioOpen(context, context.runtime.getIO(), filename, vmode, vperm, opt);
}
代码示例来源:origin: org.jruby/jruby-complete
static void createBasicSocket(Ruby runtime) {
RubyClass rb_cBasicSocket = runtime.defineClass("BasicSocket", runtime.getIO(), BASICSOCKET_ALLOCATOR);
rb_cBasicSocket.defineAnnotatedMethods(RubyBasicSocket.class);
rb_cBasicSocket.undefineMethod("initialize");
}
代码示例来源:origin: org.jruby/jruby-core
static void createBasicSocket(Ruby runtime) {
RubyClass rb_cBasicSocket = runtime.defineClass("BasicSocket", runtime.getIO(), BASICSOCKET_ALLOCATOR);
rb_cBasicSocket.defineAnnotatedMethods(RubyBasicSocket.class);
rb_cBasicSocket.undefineMethod("initialize");
}
代码示例来源:origin: org.jruby/jruby-complete
public static IRubyObject directory_p(ThreadContext context, IRubyObject filename) {
if (!(filename instanceof RubyIO) && filename.respondsTo("to_io")) {
filename = TypeConverter.convertToType(filename, context.runtime.getIO(), "to_io");
}
return context.runtime.newBoolean(fileResource(context, filename).isDirectory());
}
代码示例来源:origin: org.jruby/jruby-complete
public RubyIO(Ruby runtime, ShellLauncher.POpenProcess process, IOOptions ioOptions) {
super(runtime, runtime.getIO());
ioOptions = updateIOOptionsFromOptions(runtime.getCurrentContext(), null, ioOptions);
openFile = MakeOpenFile();
setupPopen(runtime, ioOptions.getModeFlags(), process);
}
代码示例来源:origin: org.jruby/jruby-core
public static IRubyObject directory_p(ThreadContext context, IRubyObject filename) {
if (!(filename instanceof RubyIO) && filename.respondsTo("to_io")) {
filename = TypeConverter.convertToType(filename, context.runtime.getIO(), "to_io");
}
return context.runtime.newBoolean(fileResource(context, filename).isDirectory());
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
@JRubyMethod(name = "reopen", required = 1, optional = 1)
public IRubyObject reopen(ThreadContext context, IRubyObject[] args) {
Ruby runtime = context.runtime;
IRubyObject tmp = TypeConverter.convertToTypeWithCheck(args[0], runtime.getIO(), "to_io");
if (!tmp.isNil()) {
reopenIO(runtime, (RubyIO) tmp);
} else {
reopenPath(runtime, args);
}
return this;
}
代码示例来源:origin: org.jruby/jruby-core
public RubyIO(Ruby runtime, ShellLauncher.POpenProcess process, IOOptions ioOptions) {
super(runtime, runtime.getIO());
ioOptions = updateIOOptionsFromOptions(runtime.getCurrentContext(), null, ioOptions);
openFile = MakeOpenFile();
setupPopen(runtime, ioOptions.getModeFlags(), process);
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
@JRubyMethod(name = "reopen", required = 1, optional = 1)
public IRubyObject reopen(ThreadContext context, IRubyObject[] args) {
Ruby runtime = context.runtime;
IRubyObject tmp = TypeConverter.convertToTypeWithCheck(args[0], runtime.getIO(), "to_io");
if (!tmp.isNil()) {
reopenIO(runtime, (RubyIO) tmp);
} else {
reopenPath(runtime, args);
}
return this;
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
@JRubyMethod(required = 1, optional = 2, module = true, visibility = PRIVATE, compat = RUBY1_8)
public static IRubyObject open(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) {
String arg = args[0].convertToString().toString();
Ruby runtime = context.runtime;
// exec process, create IO with process
if (arg.startsWith("|")) return RubyIO.popen(context, runtime.getIO(), popenArgs(runtime, arg, args), block);
return RubyFile.open(context, runtime.getFile(), args, block);
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
@JRubyMethod(required = 1, optional = 2, module = true, visibility = PRIVATE, compat = RUBY1_8)
public static IRubyObject open(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) {
String arg = args[0].convertToString().toString();
Ruby runtime = context.runtime;
// exec process, create IO with process
if (arg.startsWith("|")) return RubyIO.popen(context, runtime.getIO(), popenArgs(runtime, arg, args), block);
return RubyFile.open(context, runtime.getFile(), args, block);
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
public static IRubyObject directory_p(ThreadContext context, IRubyObject filename) {
Ruby runtime = context.runtime;
if (!(filename instanceof RubyFile || filename instanceof RubyIO)) {
if (filename.respondsTo("to_io")) {
filename = (RubyIO) TypeConverter.convertToType(filename, context.runtime.getIO(), "to_io");
} else {
filename = get_path(context, filename);
}
}
FileResource file = fileResource(filename);
return runtime.newBoolean(file.exists() && file.isDirectory());
}
代码示例来源:origin: org.jruby/jruby-core
public RubyIO(Ruby runtime, InputStream inputStream) {
super(runtime, runtime.getIO());
if (inputStream == null) {
throw runtime.newRuntimeError("Opening null stream");
}
openFile = MakeOpenFile();
openFile.setFD(new ChannelFD(readableChannel(inputStream), runtime.getPosix(), runtime.getFilenoUtil()));
openFile.setMode(OpenFile.READABLE);
}
代码示例来源:origin: org.jruby/jruby-complete
@JRubyMethod(name = "size", required = 1, module = true)
public static IRubyObject size(ThreadContext context, IRubyObject recv, IRubyObject filename) {
if (!(filename instanceof RubyFile) && filename.respondsTo("to_io")) {
filename = TypeConverter.convertToType(filename, context.runtime.getIO(), "to_io");
}
FileStat stat = fileResource(filename).stat();
if (stat == null) noFileError(filename);
return context.runtime.newFixnum(stat.st_size());
}
代码示例来源:origin: org.jruby/jruby-complete
public RubyIO(Ruby runtime, InputStream inputStream) {
super(runtime, runtime.getIO());
if (inputStream == null) {
throw runtime.newRuntimeError("Opening null stream");
}
openFile = MakeOpenFile();
openFile.setFD(new ChannelFD(readableChannel(inputStream), runtime.getPosix(), runtime.getFilenoUtil()));
openFile.setMode(OpenFile.READABLE);
}
代码示例来源:origin: org.jruby/jruby-core
@JRubyMethod(name = "size", required = 1, module = true)
public static IRubyObject size(ThreadContext context, IRubyObject recv, IRubyObject filename) {
if (!(filename instanceof RubyFile) && filename.respondsTo("to_io")) {
filename = TypeConverter.convertToType(filename, context.runtime.getIO(), "to_io");
}
FileStat stat = fileResource(filename).stat();
if (stat == null) noFileError(filename);
return context.runtime.newFixnum(stat.st_size());
}
代码示例来源:origin: org.jruby/jruby-complete
public RubyIO(Ruby runtime, OutputStream outputStream, boolean autoclose) {
super(runtime, runtime.getIO());
// We only want IO objects with valid streams (better to error now).
if (outputStream == null) {
throw runtime.newRuntimeError("Opening null stream");
}
openFile = MakeOpenFile();
openFile.setFD(new ChannelFD(writableChannel(outputStream), runtime.getPosix(), runtime.getFilenoUtil()));
openFile.setMode(OpenFile.WRITABLE | OpenFile.APPEND);
openFile.setAutoclose(autoclose);
}
代码示例来源:origin: org.jruby/jruby-core
public RubyIO(Ruby runtime, OutputStream outputStream, boolean autoclose) {
super(runtime, runtime.getIO());
// We only want IO objects with valid streams (better to error now).
if (outputStream == null) {
throw runtime.newRuntimeError("Opening null stream");
}
openFile = MakeOpenFile();
openFile.setFD(new ChannelFD(writableChannel(outputStream), runtime.getPosix(), runtime.getFilenoUtil()));
openFile.setMode(OpenFile.WRITABLE | OpenFile.APPEND);
openFile.setAutoclose(autoclose);
}
代码示例来源:origin: org.jruby/jruby-complete
@JRubyMethod(name = "size?", required = 1, module = true)
public static IRubyObject size_p(ThreadContext context, IRubyObject recv, IRubyObject filename) {
Ruby runtime = context.runtime;
if (!(filename instanceof RubyFile) && filename.respondsTo("to_io")) {
filename = TypeConverter.convertToType(filename, runtime.getIO(), "to_io");
}
FileStat stat = fileResource(filename).stat();
if (stat == null) return runtime.getNil();
long length = stat.st_size();
return length > 0 ? runtime.newFixnum(length) : runtime.getNil();
}
代码示例来源:origin: org.jruby/jruby-core
@JRubyMethod(name = "size?", required = 1, module = true)
public static IRubyObject size_p(ThreadContext context, IRubyObject recv, IRubyObject filename) {
Ruby runtime = context.runtime;
if (!(filename instanceof RubyFile) && filename.respondsTo("to_io")) {
filename = TypeConverter.convertToType(filename, runtime.getIO(), "to_io");
}
FileStat stat = fileResource(filename).stat();
if (stat == null) return runtime.getNil();
long length = stat.st_size();
return length > 0 ? runtime.newFixnum(length) : runtime.getNil();
}
内容来源于网络,如有侵权,请联系作者删除!