Package org.jruby
Class RubyIO
java.lang.Object
org.jruby.RubyBasicObject
org.jruby.RubyObject
org.jruby.RubyIO
- All Implemented Interfaces:
Closeable,Flushable,Serializable,AutoCloseable,Cloneable,Comparable<IRubyObject>,InstanceVariables,InternalVariables,IRubyObject,CoreObjectType,IOEncodable
- Direct Known Subclasses:
FileDescriptorIO,RubyBasicSocket,RubyFile
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumstatic classstatic classstatic classRepresents a Ruby IO::TimeoutErrorError as a throwable Java exception.Nested classes/interfaces inherited from class org.jruby.RubyObject
RubyObject.DataNested classes/interfaces inherited from class org.jruby.RubyBasicObject
RubyBasicObject.FinalizerNested classes/interfaces inherited from interface org.jruby.util.io.IOEncodable
IOEncodable.ConvConfig -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final intprotected OpenFilestatic final ByteListprotected booleanIf the stream is being used for popen, we don't want to destroy the process when we close the stream.Fields inherited from class org.jruby.RubyObject
IVAR_INSPECTING_OBJECT_ALLOCATOR, OBJECT_ALLOCATOR, REIFYING_OBJECT_ALLOCATORFields inherited from class org.jruby.RubyBasicObject
ALL_F, BASICOBJECT_ALLOCATOR, COMPARE_BY_IDENTITY_F, ERR_INSECURE_SET_INST_VAR, FALSE_F, FL_USHIFT, flags, FROZEN_F, IS_OVERLAID_F, metaClass, NEVER, NIL_F, REFINED_MODULE_F, STAMP_OFFSET, TAINTED_F, UNDEF, USER0_F, USER1_F, USER2_F, USER3_F, USER4_F, USER5_F, USER6_F, USER7_F, USER8_F, USER9_F, USERA_F, VAR_TABLE_OFFSET, varTable, varTableStampFields inherited from interface org.jruby.runtime.builtin.IRubyObject
NULL_ARRAY -
Constructor Summary
ConstructorsConstructorDescriptionRubyIO(Ruby runtime, InputStream inputStream) RubyIO(Ruby runtime, OutputStream outputStream) RubyIO(Ruby runtime, OutputStream outputStream, boolean autoclose) RubyIO(Ruby runtime, RubyClass cls, ShellLauncher.POpenProcess process, RubyHash options, IOOptions ioOptions) Deprecated.Deprecated.RubyIO(Ruby runtime, ShellLauncher.POpenProcess process, IOOptions ioOptions) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddBlockingThread(RubyThread thread) Add a thread to the list of blocking threads for this IO.advise(ThreadContext context, IRubyObject[] argv) autoclose(ThreadContext context) autoclose_set(ThreadContext context, IRubyObject autoclose) binmode()Deprecated.binmode(ThreadContext context) static IRubyObjectbinread(ThreadContext context, IRubyObject recv, IRubyObject[] args) binread is just like read, except it doesn't take options and it forces mode to be "rb:ASCII-8BIT"static IRubyObjectbinwrite(ThreadContext context, IRubyObject recv, IRubyObject[] args) bytes(ThreadContext context, Block block) Deprecated.chars(ThreadContext context, Block block) Deprecated.static RubyArraycheckExecEnv(ThreadContext context, RubyHash hash) Deprecated.static voidcheckExecOptions(IRubyObject options) Deprecated.protected voidcheckLength(ThreadContext context, int len) static voidcheckPopenOptions(IRubyObject options) Deprecated.static voidcheckSpawnOptions(IRubyObject options) Deprecated.static ChannelFDcloexecOpen(Ruby runtime, RubyIO.Sysopen data) final voidclose()close(ThreadContext context) Closes all open resources for the IO.close_on_exec_p(ThreadContext context) close_on_exec_set(ThreadContext context, IRubyObject arg) close_read(ThreadContext context) close_write(ThreadContext context) closed_p(ThreadContext context) codepoints(ThreadContext context, Block block) Deprecated.static RubyIOconvertToIO(ThreadContext context, IRubyObject obj) static IRubyObjectcopy_stream(ThreadContext context, IRubyObject recv, IRubyObject[] args) static IRubyObjectcopy_stream(ThreadContext context, IRubyObject recv, IRubyObject arg0, IRubyObject arg1) static IRubyObjectcopy_stream(ThreadContext context, IRubyObject recv, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) static RubyClasscreateIOClass(ThreadContext context, RubyClass Object, RubyModule Enumerable) protected static intdoRead(ThreadContext context, OpenFile fptr, byte[] buffer, int start, int len) doReadNonblock(ThreadContext context, IRubyObject[] args, boolean exception) doReadNonblock(ThreadContext context, IRubyObject arg0, boolean exception) doReadNonblock(ThreadContext context, IRubyObject arg0, IRubyObject arg1, boolean exception) doReadNonblock(ThreadContext context, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, boolean exception) doWriteNonblock(ThreadContext context, IRubyObject[] argv, boolean useException) Deprecated.each(ThreadContext context, Block block) each(ThreadContext context, IRubyObject[] args, Block block) each(ThreadContext context, IRubyObject arg0, Block block) each(ThreadContext context, IRubyObject arg0, IRubyObject arg1, Block block) each(ThreadContext context, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, Block block) each_byte(ThreadContext context, Block block) each_byteInternal(ThreadContext context, Block block) Invoke a block for each byte.each_char(ThreadContext context, Block block) each_charInternal(ThreadContext context, Block block) each_codepoint(ThreadContext context, Block block) each_line(ThreadContext context, Block block) each_line(ThreadContext context, IRubyObject[] args, Block block) each_line(ThreadContext context, IRubyObject arg0, Block block) each_line(ThreadContext context, IRubyObject arg0, IRubyObject arg1, Block block) each_line(ThreadContext context, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, Block block) static IRubyObjectensureYieldClose(ThreadContext context, IRubyObject port, Block block) static IRubyObjectensureYieldClosePipes(ThreadContext context, IRubyObject obj, RubyIO r, RubyIO w, Block block) eof_p(ThreadContext context) external_encoding(ThreadContext context) static voidfailIfDirectory(Ruby runtime, RubyString pathStr) fcntl(ThreadContext context, IRubyObject cmd) fcntl(ThreadContext context, IRubyObject cmd, IRubyObject arg) fileno(ThreadContext context) voidflush()flush(ThreadContext context) Flushes the IO output stream.protected RubyIOflushRaw(ThreadContext context, boolean sync) static IRubyObjectfor_fd(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) static IRubyObjectforeach(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) fsync(ThreadContext context) booleanbooleangetBOM()getbyte(ThreadContext context) Read a byte.intgetByte(ThreadContext context) getc()Deprecated.getc(ThreadContext context) Get the underlying channel from this IO object.intorg.jcodings.EncodinggetEnc()org.jcodings.EncodinggetEnc2()org.jcodings.Encodingstatic ModeFlagsgetIOModes(Ruby runtime, String modesString) Deprecated.static intgetIOModesIntFromString(Ruby runtime, String modesString) Deprecated.Deprecated.Deprecated.getline(ThreadContext context, IRubyObject separator) getline(ThreadContext context, IRubyObject separator, long limit) getline using logic of gets.getline(ThreadContext context, ByteList separator) Deprecated.getline(ThreadContext context, ByteList separator, long limit) Deprecated.This is overridden in the other concrete Java builtins to provide a fast way to determine what type they are.getPath()org.jcodings.Encodinggets(ThreadContext context) Read a line.gets(ThreadContext context, IRubyObject arg) gets(ThreadContext context, IRubyObject rs, IRubyObject limit_arg) gets(ThreadContext context, IRubyObject rs, IRubyObject limit_arg, IRubyObject opt) booleangetSync()initialize(ThreadContext context, IRubyObject fileNumber, Block unused) initialize(ThreadContext context, IRubyObject fileNumber, IRubyObject second, Block unused) initialize(ThreadContext context, IRubyObject fileNumber, IRubyObject modeValue, IRubyObject options, Block unused) initialize_copy(ThreadContext context, IRubyObject _io) Initializes this object as a copy of the original, that is the parameter to this object.inspect(ThreadContext context) Returns a string containing a human-readable representation of obj.internal_encoding(ThreadContext context) protected static IRubyObjectioClose(ThreadContext context, IRubyObject io) ioctl(ThreadContext context, IRubyObject[] args) static IRubyObjectioOpen(ThreadContext context, IRubyObject filename, IRubyObject vmode, IRubyObject vperm, IRubyObject opt) Deprecated.static IRubyObjectioOpen(ThreadContext context, IRubyObject recv, IRubyObject filename, IRubyObject vmode, IRubyObject vperm, IRubyObject opt) static IRubyObjectioStaticWrite(ThreadContext context, IRubyObject recv, IRubyObject[] argv, boolean binary) booleanbooleanisClosed()Is this IO closed MRI: rb_io_closedlineno(ThreadContext context) Returns the current line number.lineno_set(ThreadContext context, IRubyObject newLineNumber) Sets the current line number.lines(ThreadContext context, Block block) Deprecated.final OpenFilestatic IRubyObjectnewInstance(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) static RubyIOstatic IOOptionsnewIOOptions(Ruby runtime, int mode) static IOOptionsnewIOOptions(Ruby runtime, long mode) static IOOptionsnewIOOptions(Ruby runtime, String mode) static IOOptionsnewIOOptions(Ruby runtime, IOOptions oldFlags, int orOflags) static IOOptionsnewIOOptions(Ruby runtime, ModeFlags modeFlags) static ModeFlagsnewModeFlags(Ruby runtime, int mode) static ModeFlagsnewModeFlags(Ruby runtime, long mode) static ModeFlagsnewModeFlags(Ruby runtime, String mode) static voidobliterateProcess(Process process) Try for around 1s to destroy the child process.op_append(ThreadContext context, IRubyObject anObject) rb_io_addstrop_binmode(ThreadContext context) static IRubyObjectopen(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) protected IOOptionspath(ThreadContext context) pid(ThreadContext context) Return the process id (pid) of the process this IO object spawned.static IRubyObjectpipe(ThreadContext context, IRubyObject recv) static IRubyObjectpipe(ThreadContext context, IRubyObject klass, Block block) static IRubyObjectpipe(ThreadContext context, IRubyObject klass, IRubyObject[] argv, Block block) Deprecated.static IRubyObjectpipe(ThreadContext context, IRubyObject klass, IRubyObject arg0, Block block) static IRubyObjectpipe(ThreadContext context, IRubyObject klass, IRubyObject arg0, IRubyObject arg1, Block block) static IRubyObjectpipe(ThreadContext context, IRubyObject klass, IRubyObject v1, IRubyObject v2, IRubyObject opt, Block block) static IRubyObjectpopen(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) static IRubyObjectpopen3(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) Deprecated.static IRubyObjectpopen4(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) Deprecated.static org.jruby.RubyIO.POpenTuplepopenSpecial(ThreadContext context, IRubyObject[] args) Deprecated.pos(ThreadContext context) pos_set(ThreadContext context, IRubyObject offset) pread(ThreadContext context, IRubyObject len, IRubyObject offset) pread(ThreadContext context, IRubyObject _length, IRubyObject _from, IRubyObject str) static RubyIOstatic RubyIOprint(ThreadContext context) print(ThreadContext context, IRubyObject arg0) print(ThreadContext context, IRubyObject[] args) Print some objects to the stream.print(ThreadContext context, IRubyObject arg0, IRubyObject arg1) static IRubyObjectprint(ThreadContext context, IRubyObject out, IRubyObject[] args) Print some objects to the stream.print(ThreadContext context, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) static IRubyObjectprint0(ThreadContext context, IRubyObject out) static IRubyObjectprint1(ThreadContext context, IRubyObject out, IRubyObject arg1) static IRubyObjectprint2(ThreadContext context, IRubyObject out, IRubyObject arg0, IRubyObject arg1) static IRubyObjectprint3(ThreadContext context, IRubyObject out, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) printf(ThreadContext context, IRubyObject[] args) static IRubyObjectprintf(ThreadContext context, IRubyObject out, IRubyObject[] args) putc(ThreadContext context, IRubyObject ch) static IRubyObjectputc(ThreadContext context, IRubyObject maybeIO, IRubyObject object) puts(ThreadContext context) puts(ThreadContext context, IRubyObject arg0) puts(ThreadContext context, IRubyObject[] args) puts(ThreadContext context, IRubyObject arg0, IRubyObject arg1) static IRubyObjectputs(ThreadContext context, IRubyObject maybeIO, IRubyObject... args) puts(ThreadContext context, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) static IRubyObjectputs0(ThreadContext context, IRubyObject maybeIO) static IRubyObjectputs1(ThreadContext context, IRubyObject maybeIO, IRubyObject arg0) static IRubyObjectputs2(ThreadContext context, IRubyObject maybeIO, IRubyObject arg0, IRubyObject arg1) static IRubyObjectputs3(ThreadContext context, IRubyObject maybeIO, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) pwrite(ThreadContext context, IRubyObject str, IRubyObject offset) protected IRubyObjectrbIoClose(ThreadContext context) read(IRubyObject[] args) Deprecated.read(ThreadContext context) Read all available bytes.intread(ThreadContext context, byte[] buffer, int start, int len) Read into the given buffer starting from start and reading len bytes.read(ThreadContext context, IRubyObject length) Read length bytes.read(ThreadContext context, IRubyObject[] args) read(ThreadContext context, IRubyObject length, IRubyObject maybeStr) Read into the given buffer (or create a new one) reading length bytes.static IRubyObjectread(ThreadContext context, IRubyObject recv, IRubyObject[] args) static IRubyObjectread(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block unusedBlock) read_nonblock(ThreadContext context, IRubyObject arg0) read_nonblock(ThreadContext context, IRubyObject[] args) Deprecated.read_nonblock(ThreadContext context, IRubyObject arg0, IRubyObject arg1) read_nonblock(ThreadContext context, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) readbyte(ThreadContext context) readchar()Deprecated.readchar(ThreadContext context) Read a char.readline(ThreadContext context) Read a line.readline(ThreadContext context, IRubyObject separator) readline(ThreadContext context, IRubyObject[] args) Deprecated.readline(ThreadContext context, IRubyObject separator, IRubyObject limit) readline(ThreadContext context, IRubyObject separator, IRubyObject limit, IRubyObject opts) readlines(ThreadContext context) readlines(ThreadContext context, IRubyObject arg0) readlines(ThreadContext context, IRubyObject[] args) readlines(ThreadContext context, IRubyObject arg0, IRubyObject arg1) static IRubyObjectreadlines(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block unusedBlock) readlines(ThreadContext context, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) readpartial(ThreadContext context, IRubyObject arg0) readpartial(ThreadContext context, IRubyObject[] args) Deprecated.readpartial(ThreadContext context, IRubyObject arg0, IRubyObject arg1) voidremoveBlockingThread(RubyThread thread) Remove a thread from the list of blocking threads for this IO.reopen(ThreadContext context, IRubyObject[] args) protected RubyIOreopenIO(ThreadContext context, RubyIO nfile) rewind(ThreadContext context) seek(ThreadContext context, IRubyObject off) seek(ThreadContext context, IRubyObject[] args) seek(ThreadContext context, IRubyObject off, IRubyObject whence) static IRubyObjectselect(ThreadContext context, IRubyObject recv, IRubyObject[] argv) static IRubyObjectselect_static(ThreadContext context, Ruby runtime, IRubyObject[] args) Deprecated.set_encoding(ThreadContext context, IRubyObject encodingObj) set_encoding(ThreadContext context, IRubyObject encodingString, IRubyObject internalEncoding) set_encoding(ThreadContext context, IRubyObject encodingString, IRubyObject internalEncoding, IRubyObject options) set_encoding_by_bom(ThreadContext context) protected RubyIOvoidsetAutoclose(boolean autoclose) voidsetBlocking(boolean blocking) voidsetBOM(boolean bom) voidsetEcflags(int ecflags) voidsetEcopts(IRubyObject ecopts) voidsetEnc(org.jcodings.Encoding enc) voidsetEnc2(org.jcodings.Encoding enc2) voidsetEncoding(ThreadContext context, IRubyObject v1, IRubyObject v2, IRubyObject opt) protected voidvoidsetSync(boolean sync) stat(ThreadContext context) sync(ThreadContext context) Returns the current sync mode.sync_set(IRubyObject sync) Deprecated.Usesync_set(ThreadContext, IRubyObject)instead.sync_set(ThreadContext context, IRubyObject sync) Sets the current sync mode.protected static ChannelFDstatic IRubyObjectsysopen(IRubyObject recv, IRubyObject[] args, Block block) Deprecated.static IRubyObjectsysopen(ThreadContext context, IRubyObject recv, IRubyObject[] argv, Block block) sysread(ThreadContext context, IRubyObject _length) sysread(ThreadContext context, IRubyObject[] args) Deprecated.sysread(ThreadContext context, IRubyObject _length, IRubyObject _str) sysseek(ThreadContext context, IRubyObject[] args) syswrite(ThreadContext context, IRubyObject str) to_io()<T> TConvert the object to the specified Java class, if possible.toString()The default toString method is just a wrapper that calls the Ruby "to_s" method.static IRubyObjecttryConvert(ThreadContext context, IRubyObject recv, IRubyObject arg) tty_p(ThreadContext context) ungetbyte(ThreadContext context, IRubyObject b) ungetc(ThreadContext context, IRubyObject c) protected IOOptionsupdateIOOptionsFromOptions(ThreadContext context, RubyHash options, IOOptions ioOptions) See http://ruby-doc.org/core-1.9.3/IO.html#method-c-new for the format of modes in optionswait(ThreadContext context, IRubyObject[] argv) static IRubyObjectwait(ThreadContext context, IRubyObject _io, IRubyObject[] argv) wait_readable(ThreadContext context, IRubyObject[] argv) static IRubyObjectwait_readable(ThreadContext context, IRubyObject _io, IRubyObject[] argv) wait_writable(ThreadContext context, IRubyObject[] argv) waits until input available or timed out and returns self, or nil when EOF reached.static IRubyObjectwait_writable(ThreadContext context, IRubyObject _io, IRubyObject[] argv) waits until input available or timed out and returns self, or nil when EOF reached.intwrite(byte[] bytes, int start, int length, org.jcodings.Encoding encoding) Same aswrite(ThreadContext, byte[], int, int, Encoding, boolean)but context will be retrieved and nosync defaults to false.intwrite(byte[] bytes, int start, int length, org.jcodings.Encoding encoding, boolean nosync) Same aswrite(ThreadContext, byte[], int, int, Encoding, boolean)but context will be retrieved.intwrite(byte[] bytes, org.jcodings.Encoding encoding) Same aswrite(ThreadContext, byte[], int, int, Encoding, boolean)but context will be retrieved nosync defaults to false, and the entire byte array will be written.voidwrite(int bite) Same aswrite(ThreadContext, byte)but context will be retrieved.final voidwrite(ThreadContext context, byte ch) Write a single byte to this IO's write target but do not return the number of bytes written (it will be 1).intwrite(ThreadContext context, byte[] bytes, int start, int length, org.jcodings.Encoding encoding) Write the given range of bytes to this IO.intwrite(ThreadContext context, byte[] bytes, int start, int length, org.jcodings.Encoding encoding, boolean nosync) Write the given range of bytes to this IO.final IRubyObjectwrite(ThreadContext context, int ch) Write a single byte to this IO's write target.write(ThreadContext context, IRubyObject str) Ruby method IO#write(str), equivalent to io_write_m.write(ThreadContext context, IRubyObject[] args) Ruby method IO#write(str, ...), equivalent to io_write_m.write(ThreadContext context, IRubyObject str, boolean nosync) Write the given range of bytes to this IO's write target.static IRubyObjectwrite(ThreadContext context, IRubyObject maybeIO, IRubyObject str) static IRubyObjectwrite(ThreadContext context, IRubyObject recv, IRubyObject[] argv) static IRubyObjectwrite(ThreadContext context, IRubyObject maybeIO, IRubyObject arg0, IRubyObject arg1) protected static IRubyObjectwrite(ThreadContext context, IRubyObject maybeIO, ByteList byteList) protected static IRubyObjectwrite(ThreadContext context, IRubyObject maybeIO, ByteList byteList, IRubyObject sep) write_nonblock(ThreadContext context, IRubyObject arg0) write_nonblock(ThreadContext context, IRubyObject[] argv) Deprecated.write_nonblock(ThreadContext context, IRubyObject arg0, IRubyObject arg1) write2(ThreadContext context, IRubyObject arg0, IRubyObject arg1) Ruby method IO#write(str, ...), equivalent to io_write_m.write3(ThreadContext context, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) Ruby method IO#write(str, ...), equivalent to io_write_m.static IRubyObjectwriteStatic(ThreadContext context, IRubyObject recv, IRubyObject[] argv, Block unusedBlock) Deprecated.static IRubyObjectwritev(ThreadContext context, IRubyObject io) static IRubyObjectwritev(ThreadContext context, IRubyObject io, IRubyObject arg0) static IRubyObjectwritev(ThreadContext context, IRubyObject io, IRubyObject[] args) static IRubyObjectwritev(ThreadContext context, IRubyObject io, IRubyObject arg0, IRubyObject arg1) static IRubyObjectwritev(ThreadContext context, IRubyObject io, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) Methods inherited from class org.jruby.RubyObject
attachToObjectSpace, callInit, callInit, callInit, callInit, callInit, callInit, callInit, callInit, callInit, callInit, convertToType, dig, dig1, dig2, eqlInternal, equalInternal, equals, finishObjectClass, hashCode, inspect, op_eqq, puts, specificEval, toRubyStringMethods inherited from class org.jruby.RubyBasicObject
addFinalizer, addFinalizer, anyToString, asJavaString, asString, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callSuper, checkArrayType, checkCallMethod, checkCallMethod, checkFrozen, checkStringType, cloneSetup, compareTo, convertToArray, convertToFloat, convertToHash, convertToInteger, convertToInteger, convertToInteger, convertToString, copyInstanceVariablesInto, copySpecialInstanceVariables, dataGetStruct, dataGetStructChecked, dataWrapStruct, decode, display, dup, dupFinalizer, dupSetup, ensureInstanceVariablesSettable, eql, eql_p, eql_p, equal_p, evalUnder, extend, fastGetInstanceVariable, fastGetInternalVariable, fastHasInstanceVariable, fastHasInternalVariable, fastSetInstanceVariable, fastSetInternalVariable, finishBasicObjectClass, forEachInstanceVariable, forEachInstanceVariableName, freeze, frozen_p, getCurrentContext, getFFIHandle, getFlag, getInstanceEvalClass, getInstanceEvalClass, getInstanceVariable, getInstanceVariableList, getInstanceVariableNameList, getInstanceVariables, getInternalVariable, getInternalVariables, getJavaClass, getMarshalVariableList, getMetaClass, getMetaClass, getNativeHandle, getNativeTypeIndex, getObjectId, getRuntime, getSingletonClass, getSingletonClassClone, getSingletonClassCloneAndAttach, getSingletonClassCloneAndAttach, getType, getVariable, getVariableCount, getVariableList, getVariableNameList, hash, hash, hashyInspect, hasInstanceVariable, hasInstanceVariables, hasInternalVariable, hasVariables, id, infectBy, initialize, initialize_copy, inspect, inspectHashCode, instance_eval, instance_eval, instance_eval, instance_eval, instance_eval, instance_exec, instance_of_p, instance_variable_defined_p, instance_variable_get, instance_variable_set, instance_variables, isBuiltin, isClass, isFalse, isFrozen, isImmediate, isModule, isNil, isSpecialConst, isSpecialObject, isTaint, isTrue, isUntrusted, kind_of_p, makeMetaClass, makeMetaClass, makeMetaClassBootstrap, method, method, method, method_missing, methods, methods, nil_p, nonFixnumHashCode, nonFixnumHashCode, OBJ_INIT_COPY, objInitCopy, op_cmp, op_equal, op_match, op_not, op_not_equal, op_not_match, private_methods, protected_methods, public_methods, rbClone, rbClone, rbInspect, remove_instance_variable, removeFinalizers, removeInstanceVariable, removeInternalVariable, respond_to_p, respond_to_p, respondsTo, respondsToMissing, respondsToMissing, send, send, send, send, send, setFFIHandle, setFlag, setFrozen, setInstanceVariable, setInternalVariable, setMetaClass, setNativeHandle, setTaint, setUntrusted, setVariable, singleton_method, singleton_method, singleton_method_added, singleton_method_removed, singleton_method_undefined, singleton_methods, singletonClass, specificEval, specificEval, specificEval, specificEval, syncVariables, syncVariables, taint, taint, tainted_p, testFrozen, testFrozen, to_a, to_a, to_s, to_s, trust, type, untaint, untrust, untrusted_p, validateInstanceVariable, validateInstanceVariable, validateInstanceVariable, variableTableContains, variableTableFastContains, variableTableFastFetch, variableTableFastStore, variableTableFetch, variableTableRemove, variableTableStore, variableTableSync, yieldUnder, yieldUnderMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.jruby.runtime.builtin.IRubyObject
checkStringType19, dup, marshalLiveVariables
-
Field Details
-
PARAGRAPH_SEPARATOR
-
CLOSED_STREAM_MSG
- See Also:
-
FD_CLOEXEC
public static final int FD_CLOEXEC- See Also:
-
openFile
-
popenSpecial
protected boolean popenSpecialIf the stream is being used for popen, we don't want to destroy the process when we close the stream.
-
-
Constructor Details
-
RubyIO
-
RubyIO
-
RubyIO
-
RubyIO
-
RubyIO
-
RubyIO
-
RubyIO
-
RubyIO
Deprecated. -
RubyIO
@Deprecated public RubyIO(Ruby runtime, RubyClass cls, ShellLauncher.POpenProcess process, RubyHash options, IOOptions ioOptions) Deprecated.
-
-
Method Details
-
prepStdio
-
prepStdio
-
newIO
-
getOpenFile
-
getOpenFileChecked
-
getOpenFileInitialized
-
getNativeClassIndex
Description copied from class:RubyObjectThis is overridden in the other concrete Java builtins to provide a fast way to determine what type they are. Will generally return a value from org.jruby.runtime.ClassIndex- Specified by:
getNativeClassIndexin interfaceCoreObjectType- Overrides:
getNativeClassIndexin classRubyObject- Returns:
- the ClassIndex of the native type this object was constructed from
- See Also:
-
createIOClass
public static RubyClass createIOClass(ThreadContext context, RubyClass Object, RubyModule Enumerable) -
getOutStream
-
getInStream
-
getChannel
Get the underlying channel from this IO object. Note that IO buffers data internally, so the channel returned here may have been read into those buffers. If the channel and the IO are both being used at the same time, the stream will get out of sync.- Returns:
- the underlying channel for this IO
-
reopenIO
-
reopen
-
getline
-
getline
getline using logic of gets. If limit is -1 then read unlimited amount. -
getEnc
public org.jcodings.Encoding getEnc()- Specified by:
getEncin interfaceIOEncodable
-
getReadEncoding
public org.jcodings.Encoding getReadEncoding() -
getEnc2
public org.jcodings.Encoding getEnc2()- Specified by:
getEnc2in interfaceIOEncodable
-
getInputEncoding
public org.jcodings.Encoding getInputEncoding() -
newInstance
public static IRubyObject newInstance(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) -
for_fd
public static IRubyObject for_fd(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) -
initialize
-
initialize
public IRubyObject initialize(ThreadContext context, IRubyObject fileNumber, IRubyObject second, Block unused) -
initialize
public IRubyObject initialize(ThreadContext context, IRubyObject fileNumber, IRubyObject modeValue, IRubyObject options, Block unused) -
parseIOOptions
-
external_encoding
-
internal_encoding
-
set_encoding
-
set_encoding
public IRubyObject set_encoding(ThreadContext context, IRubyObject encodingString, IRubyObject internalEncoding) -
set_encoding
public IRubyObject set_encoding(ThreadContext context, IRubyObject encodingString, IRubyObject internalEncoding, IRubyObject options) -
set_encoding_by_bom
-
setEncoding
-
open
public static IRubyObject open(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) -
ensureYieldClose
-
sysopen
Deprecated. -
sysopen
public static IRubyObject sysopen(ThreadContext context, IRubyObject recv, IRubyObject[] argv, Block block) -
sysopen
-
cloexecOpen
-
isAutoclose
public boolean isAutoclose() -
setAutoclose
public void setAutoclose(boolean autoclose) -
autoclose
-
autoclose_set
-
binmode
Deprecated.Usebinmode(ThreadContext)instead.- Returns:
-
binmode
-
op_binmode
-
syswrite
-
write_nonblock
-
write_nonblock
-
GetWriteIO
-
write
Ruby method IO#write(str), equivalent to io_write_m.- Parameters:
context- the current contextstr- the string to write
-
write2
Ruby method IO#write(str, ...), equivalent to io_write_m.- Parameters:
context- the current contextarg0- the first string to writearg1- the second string to write
-
write3
public IRubyObject write3(ThreadContext context, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) Ruby method IO#write(str, ...), equivalent to io_write_m.- Parameters:
context- the current contextarg0- the first string to writearg1- the second string to writearg2- the third string to write
-
write
Ruby method IO#write(str, ...), equivalent to io_write_m.- Parameters:
context- the current contextargs- the strings to write
-
write
Write a single byte to this IO's write target.- Parameters:
context- the current contextch- the byte to write, as an int- Returns:
- the count of bytes written
-
write
Write a single byte to this IO's write target but do not return the number of bytes written (it will be 1). This version does not dig out any wrapped write IO (bytes will be written to this IO).- Parameters:
context- the current contextch- the byte to write, as an int
-
write
Write the given range of bytes to this IO's write target. Equivalent to io_write.- Parameters:
context- the current contextstr- the string to writenosync- whether to write without syncing- Returns:
- the count of bytes written
-
write
public int write(ThreadContext context, byte[] bytes, int start, int length, org.jcodings.Encoding encoding) Write the given range of bytes to this IO. Equivalent to io_write_m with source bytes and no digging out any wrapped write IO (bytes will be written to this IO).- Parameters:
context- the current contextbytes- the bytes to writestart- start offset for writinglength- length to writeencoding- encoding of the bytes (will not be verified)- Returns:
- the count of bytes written
-
write
public int write(ThreadContext context, byte[] bytes, int start, int length, org.jcodings.Encoding encoding, boolean nosync) Write the given range of bytes to this IO. Equivalent to io_write with source bytes and no digging out any wrapped write IO (bytes will be written to this IO.- Parameters:
context- the current contextbytes- the bytes to writestart- start offset for writinglength- length to writeencoding- encoding of the bytes (will not be verified)nosync- whether to write without syncing- Returns:
- the count of bytes written
-
write
public int write(byte[] bytes, int start, int length, org.jcodings.Encoding encoding, boolean nosync) Same aswrite(ThreadContext, byte[], int, int, Encoding, boolean)but context will be retrieved. Heavy use should retrieve context once and call the original method to avoid thread-local overhead.- Parameters:
bytes- the bytes to writestart- start offset for writinglength- length to writeencoding- encoding of the bytes (will not be verified)nosync- whether to write without syncing- Returns:
- the count of bytes written
-
write
public int write(byte[] bytes, int start, int length, org.jcodings.Encoding encoding) Same aswrite(ThreadContext, byte[], int, int, Encoding, boolean)but context will be retrieved and nosync defaults to false. Heavy use should retrieve context once and call the original method to avoid thread-local overhead.- Parameters:
bytes- the bytes to writestart- start offset for writinglength- length to writeencoding- encoding of the bytes (will not be verified)- Returns:
- the count of bytes written
-
write
public int write(byte[] bytes, org.jcodings.Encoding encoding) Same aswrite(ThreadContext, byte[], int, int, Encoding, boolean)but context will be retrieved nosync defaults to false, and the entire byte array will be written. Heavy use should retrieve context once and call the original method to avoid thread-local overhead.- Parameters:
bytes- the bytes to writeencoding- encoding of the bytes (will not be verified)- Returns:
- the count of bytes written
-
write
public void write(int bite) Same aswrite(ThreadContext, byte)but context will be retrieved. Heavy use should retrieve context once and call the original method to avoid thread-local overhead.- Parameters:
bite- the byte to write, as an int
-
op_append
rb_io_addstr -
fileno
-
lineno
Returns the current line number.- Returns:
- the current line number.
-
lineno_set
Sets the current line number.- Parameters:
newLineNumber- The new line number.
-
sync
Returns the current sync mode. MRI: rb_io_sync- Returns:
- the current sync mode.
-
pid
Return the process id (pid) of the process this IO object spawned. If no process exists (popen was not called), then nil is returned. This is not how it appears to be defined but ruby 1.8 works this way.
- Returns:
- the pid or nil
-
pos
-
pos_set
-
print
Print some objects to the stream. -
print
-
print
-
print
-
print
public IRubyObject print(ThreadContext context, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) -
print
Print some objects to the stream. MRI: rb_io_print -
print0
-
print1
-
print2
public static IRubyObject print2(ThreadContext context, IRubyObject out, IRubyObject arg0, IRubyObject arg1) -
print3
public static IRubyObject print3(ThreadContext context, IRubyObject out, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) -
printf
-
printf
-
putc
-
putc
-
seek
-
seek
-
seek
-
sysseek
-
rewind
-
fsync
-
sync_set
Deprecated.Usesync_set(ThreadContext, IRubyObject)instead.- Parameters:
sync-- Returns:
-
sync_set
Sets the current sync mode. MRI: rb_io_set_sync- Parameters:
sync- The new sync mode.
-
setSync
public void setSync(boolean sync) -
getSync
public boolean getSync() -
eof_p
-
tty_p
-
initialize_copy
Description copied from class:RubyBasicObjectInitializes this object as a copy of the original, that is the parameter to this object. Will make sure that the argument actually has the same real class as this object. It shouldn't be possible to initialize an object with something totally different.- Overrides:
initialize_copyin classRubyBasicObject- Parameters:
context- the thread context_io- the original- Returns:
- a copy unless the same thing
-
closed_p
-
isClosed
public boolean isClosed()Is this IO closed MRI: rb_io_closed- Returns:
- true if closed
-
close
Closes all open resources for the IO. It also removes it from our magical all open file descriptor pool.
- Returns:
- The IO. Returns nil if the IO was already closed. MRI: rb_io_close_m
-
close
public final void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
ioClose
-
rbIoClose
-
close_write
-
close_read
-
close_on_exec_set
-
close_on_exec_p
-
flush
Flushes the IO output stream. MRI: rb_io_flush- Returns:
- The IO.
-
flush
public void flush() -
flushRaw
-
gets
Read a line. -
gets
-
gets
-
gets
public IRubyObject gets(ThreadContext context, IRubyObject rs, IRubyObject limit_arg, IRubyObject opt) -
getBlocking
public boolean getBlocking() -
setBlocking
public void setBlocking(boolean blocking) -
fcntl
-
fcntl
-
ioctl
-
puts
-
puts
-
puts
-
puts
public IRubyObject puts(ThreadContext context, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) -
puts
-
puts0
-
puts1
-
puts2
public static IRubyObject puts2(ThreadContext context, IRubyObject maybeIO, IRubyObject arg0, IRubyObject arg1) -
puts3
public static IRubyObject puts3(ThreadContext context, IRubyObject maybeIO, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) -
puts
-
write
-
write
protected static IRubyObject write(ThreadContext context, IRubyObject maybeIO, ByteList byteList, IRubyObject sep) -
write
-
write
public static IRubyObject write(ThreadContext context, IRubyObject maybeIO, IRubyObject arg0, IRubyObject arg1) -
writev
-
writev
-
writev
-
writev
public static IRubyObject writev(ThreadContext context, IRubyObject io, IRubyObject arg0, IRubyObject arg1) -
writev
public static IRubyObject writev(ThreadContext context, IRubyObject io, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) -
inspect
Description copied from class:RubyBasicObjectReturns a string containing a human-readable representation of obj. If not overridden, uses theto_smethod to generate the string. [ 1, 2, 3..4, 'five' ].inspect #=> "[1, 2, 3..4, \"five\"]" Time.new.inspect #=> "Wed Apr 09 08:54:39 CDT 2003"- Specified by:
inspectin interfaceIRubyObject- Overrides:
inspectin classRubyBasicObject
-
readline
Read a line. -
readline
-
readline
-
readline
public IRubyObject readline(ThreadContext context, IRubyObject separator, IRubyObject limit, IRubyObject opts) -
getc
Deprecated. -
readchar
Read a char. On EOF throw EOFError. -
getbyte
Read a byte. On EOF returns nil. -
getByte
-
readbyte
-
getc
-
ungetbyte
-
ungetc
-
read_nonblock
-
read_nonblock
-
read_nonblock
public IRubyObject read_nonblock(ThreadContext context, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) -
doReadNonblock
-
doReadNonblock
public IRubyObject doReadNonblock(ThreadContext context, IRubyObject arg0, IRubyObject arg1, boolean exception) -
doReadNonblock
public IRubyObject doReadNonblock(ThreadContext context, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, boolean exception) -
doReadNonblock
-
readpartial
-
readpartial
-
sysread
-
sysread
-
read
Deprecated. -
read
-
read
Read all available bytes. Equivalent to io_read with no arguments.- Parameters:
context- the current context- Returns:
- the output buffer viewing the actual range of bytes read
-
read
Read length bytes. Equivalent to io_read with a length argument.- Parameters:
context- the current contextlength- a numeric value of the count of bytes to read- Returns:
- the output buffer viewing the actual range of bytes read
-
read
Read into the given buffer (or create a new one) reading length bytes. Equivalent to io_read.- Parameters:
context- the current contextlength- a numeric value of the count of bytes to readmaybeStr- a RubyString buffer or a nil to indicate a new buffer should be created- Returns:
- the output buffer viewing the actual range of bytes read
-
checkLength
-
read
Read into the given buffer starting from start and reading len bytes. Equivalent to io_read with target byte[] buffer already in hand.- Parameters:
context- the current contextbuffer- the target bufferstart- start offset in target bufferlen- count of bytes to read- Returns:
- the number of bytes actually read or -1 for EOF
-
doRead
protected static int doRead(ThreadContext context, OpenFile fptr, byte[] buffer, int start, int len) -
readchar
Deprecated. -
stat
-
each_byteInternal
Invoke a block for each byte.
MRI: rb_io_each_byte -
each_byte
-
bytes
Deprecated. -
each_charInternal
-
each_char
-
chars
Deprecated. -
codepoints
Deprecated. -
each_codepoint
-
each
-
each
-
each
-
each
public IRubyObject each(ThreadContext context, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, Block block) -
each
-
each_line
-
each_line
-
each_line
public IRubyObject each_line(ThreadContext context, IRubyObject arg0, IRubyObject arg1, Block block) -
each_line
public IRubyObject each_line(ThreadContext context, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, Block block) -
each_line
-
lines
Deprecated. -
readlines
-
readlines
-
readlines
-
readlines
public RubyArray readlines(ThreadContext context, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) -
readlines
-
to_io
-
toString
Description copied from class:RubyObjectThe default toString method is just a wrapper that calls the Ruby "to_s" method.- Overrides:
toStringin classRubyObject- Returns:
- string representation
-
foreach
public static IRubyObject foreach(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) -
convertToIO
-
select
-
wait_readable
-
wait_writable
waits until input available or timed out and returns self, or nil when EOF reached. -
wait
-
advise
-
failIfDirectory
-
ioOpen
public static IRubyObject ioOpen(ThreadContext context, IRubyObject recv, IRubyObject filename, IRubyObject vmode, IRubyObject vperm, IRubyObject opt) -
binread
binread is just like read, except it doesn't take options and it forces mode to be "rb:ASCII-8BIT"- Parameters:
context- the current ThreadContextrecv- the target of the call (IO or a subclass)args- arguments; path [, length [, offset]]- Returns:
- the binary contents of the given file, at specified length and offset
-
read
public static IRubyObject read(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block unusedBlock) -
read
-
binwrite
-
write
-
ioStaticWrite
public static IRubyObject ioStaticWrite(ThreadContext context, IRubyObject recv, IRubyObject[] argv, boolean binary) -
readlines
public static IRubyObject readlines(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block unusedBlock) -
popen
public static IRubyObject popen(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) -
pipe
-
pipe
-
pipe
public static IRubyObject pipe(ThreadContext context, IRubyObject klass, IRubyObject arg0, Block block) -
pipe
public static IRubyObject pipe(ThreadContext context, IRubyObject klass, IRubyObject arg0, IRubyObject arg1, Block block) -
pipe
public static IRubyObject pipe(ThreadContext context, IRubyObject klass, IRubyObject v1, IRubyObject v2, IRubyObject opt, Block block) -
ensureYieldClosePipes
public static IRubyObject ensureYieldClosePipes(ThreadContext context, IRubyObject obj, RubyIO r, RubyIO w, Block block) -
copy_stream
public static IRubyObject copy_stream(ThreadContext context, IRubyObject recv, IRubyObject arg0, IRubyObject arg1) -
copy_stream
public static IRubyObject copy_stream(ThreadContext context, IRubyObject recv, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) -
copy_stream
-
tryConvert
-
pread
-
pread
public IRubyObject pread(ThreadContext context, IRubyObject _length, IRubyObject _from, IRubyObject str) -
pwrite
-
wait_readable
-
wait_writable
waits until input available or timed out and returns self, or nil when EOF reached. -
wait
-
path
-
getPath
-
setPath
-
addBlockingThread
Add a thread to the list of blocking threads for this IO.- Parameters:
thread- A thread blocking on this IO
-
removeBlockingThread
Remove a thread from the list of blocking threads for this IO.- Parameters:
thread- A thread blocking on this IO
-
updateIOOptionsFromOptions
protected IOOptions updateIOOptionsFromOptions(ThreadContext context, RubyHash options, IOOptions ioOptions) See http://ruby-doc.org/core-1.9.3/IO.html#method-c-new for the format of modes in options -
checkExecOptions
Deprecated. -
checkSpawnOptions
Deprecated. -
checkPopenOptions
Deprecated. -
obliterateProcess
Try for around 1s to destroy the child process. This is to work around issues on some JVMs where if you try to destroy the process too quickly it may not be ready and may ignore the destroy. A subsequent waitFor will then hang. This version tries to destroy and call exitValue repeatedly for up to 1000 calls with 1ms delay between iterations, with the intent that the target process ought to be "ready to die" fairly quickly and we don't get stuck in a blocking waitFor call.- Parameters:
process- The process to obliterate
-
newModeFlags
-
newModeFlags
-
newModeFlags
-
newIOOptions
-
newIOOptions
-
newIOOptions
-
newIOOptions
-
newIOOptions
-
readline
Deprecated. -
setEnc2
public void setEnc2(org.jcodings.Encoding enc2) - Specified by:
setEnc2in interfaceIOEncodable
-
setEnc
public void setEnc(org.jcodings.Encoding enc) - Specified by:
setEncin interfaceIOEncodable
-
setEcflags
public void setEcflags(int ecflags) - Specified by:
setEcflagsin interfaceIOEncodable
-
getEcflags
public int getEcflags()- Specified by:
getEcflagsin interfaceIOEncodable
-
setEcopts
- Specified by:
setEcoptsin interfaceIOEncodable
-
getEcopts
- Specified by:
getEcoptsin interfaceIOEncodable
-
setBOM
public void setBOM(boolean bom) - Specified by:
setBOMin interfaceIOEncodable
-
getBOM
public boolean getBOM()- Specified by:
getBOMin interfaceIOEncodable
-
toJava
Description copied from interface:IRubyObjectConvert the object to the specified Java class, if possible.- Specified by:
toJavain interfaceIRubyObject- Overrides:
toJavain classRubyBasicObject- Type Parameters:
T- type- Parameters:
target- The target type to which the object should be converted.- Returns:
- java type
- See Also:
-
setAscii8bitBinmode
-
MakeOpenFile
-
getline
Deprecated. -
getline
Deprecated. -
getline
Deprecated. -
getline
Deprecated. -
getIOModes
Deprecated. -
getIOModesIntFromString
Deprecated. -
writeStatic
@Deprecated public static IRubyObject writeStatic(ThreadContext context, IRubyObject recv, IRubyObject[] argv, Block unusedBlock) Deprecated. -
popen3
@Deprecated public static IRubyObject popen3(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) Deprecated. -
popen4
@Deprecated public static IRubyObject popen4(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) Deprecated. -
popenSpecial
@Deprecated public static org.jruby.RubyIO.POpenTuple popenSpecial(ThreadContext context, IRubyObject[] args) Deprecated. -
doWriteNonblock
@Deprecated public IRubyObject doWriteNonblock(ThreadContext context, IRubyObject[] argv, boolean useException) Deprecated. -
select_static
@Deprecated public static IRubyObject select_static(ThreadContext context, Ruby runtime, IRubyObject[] args) Deprecated. -
checkExecEnv
Deprecated. -
ioOpen
@Deprecated public static IRubyObject ioOpen(ThreadContext context, IRubyObject filename, IRubyObject vmode, IRubyObject vperm, IRubyObject opt) Deprecated. -
write_nonblock
Deprecated. -
read_nonblock
Deprecated. -
readpartial
Deprecated. -
sysread
Deprecated. -
pipe
@Deprecated public static IRubyObject pipe(ThreadContext context, IRubyObject klass, IRubyObject[] argv, Block block) Deprecated.
-
binmode(ThreadContext)instead.