org.jruby
Class RubyIO
java.lang.Object
org.jruby.RubyBasicObject
org.jruby.RubyObject
org.jruby.RubyIO
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<IRubyObject>, InstanceVariables, InternalVariables, IRubyObject, CoreObjectType
- Direct Known Subclasses:
- FileDescriptorIO, RubyBasicSocket, RubyFile
public class RubyIO
- extends RubyObject
- Author:
- jpetersen
- See Also:
- Serialized Form
Fields 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, metaClass, NEVER, NIL_F, TAINTED_F, UNDEF, UNTRUSTED_F, USER0_F, USER1_F, USER2_F, USER3_F, USER4_F, USER5_F, USER6_F, USER7_F, USER8_F |
Method Summary |
void |
addBlockingThread(RubyThread thread)
Add a thread to the list of blocking threads for this IO. |
IRubyObject |
autoclose_set(ThreadContext context,
IRubyObject autoclose)
|
IRubyObject |
autoclose(ThreadContext context)
|
IRubyObject |
binmode()
|
static IRubyObject |
binread(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" |
IRubyObject |
bytes(ThreadContext context)
|
IRubyObject |
chars(ThreadContext context,
Block block)
|
IRubyObject |
close_read(ThreadContext context)
|
IRubyObject |
close_write(ThreadContext context)
|
IRubyObject |
close()
Closes all open resources for the IO. |
protected IRubyObject |
close2(Ruby runtime)
|
RubyBoolean |
closed_p(ThreadContext context)
|
IRubyObject |
codepoints(ThreadContext context,
Block block)
|
static RubyIO |
convertToIO(ThreadContext context,
IRubyObject obj)
|
static IRubyObject |
copy_stream(ThreadContext context,
IRubyObject recv,
IRubyObject arg1,
IRubyObject arg2)
|
static RubyClass |
createIOClass(Ruby runtime)
|
IRubyObject |
ctl(Ruby runtime,
IRubyObject cmd,
IRubyObject arg)
|
IRubyObject |
each_byte(ThreadContext context,
Block block)
|
IRubyObject |
each_byteInternal(ThreadContext context,
Block block)
Invoke a block for each byte. |
IRubyObject |
each_char(ThreadContext context,
Block block)
|
IRubyObject |
each_charInternal(ThreadContext context,
Block block)
|
IRubyObject |
each_codepoint(ThreadContext context,
Block block)
|
IRubyObject |
each_line(ThreadContext context,
IRubyObject[] args,
Block block)
|
RubyIO |
each_lineInternal(ThreadContext context,
IRubyObject[] args,
Block block)
Invoke a block for each line. |
IRubyObject |
each(ThreadContext context,
IRubyObject[] args,
Block block)
|
protected static boolean |
emptyBufferOrEOF(org.jruby.util.ByteList buffer,
OpenFile myOpenFile)
|
RubyBoolean |
eof_p(ThreadContext context)
|
IRubyObject |
external_encoding(ThreadContext context)
|
static void |
failIfDirectory(Ruby runtime,
RubyString pathStr)
|
IRubyObject |
fcntl(ThreadContext context,
IRubyObject cmd)
|
IRubyObject |
fcntl(ThreadContext context,
IRubyObject cmd,
IRubyObject arg)
|
protected Stream |
fdopen(ChannelDescriptor existingDescriptor,
ModeFlags modes)
|
RubyFixnum |
fileno(ThreadContext context)
|
RubyIO |
flush()
Flushes the IO output stream. |
static IRubyObject |
foreach(ThreadContext context,
IRubyObject recv,
IRubyObject[] args,
Block block)
|
static IRubyObject |
foreach19(ThreadContext context,
IRubyObject recv,
IRubyObject[] args,
Block block)
|
static IRubyObject |
foreachInternal(ThreadContext context,
IRubyObject recv,
IRubyObject[] args,
Block block)
rb_io_s_foreach |
static IRubyObject |
foreachInternal19(ThreadContext context,
IRubyObject recv,
IRubyObject[] args,
Block block)
rb_io_s_foreach |
RubyFixnum |
fsync(ThreadContext context)
|
protected int |
fwrite(org.jruby.util.ByteList buffer)
|
boolean |
getBlocking()
|
IRubyObject |
getbyte19(ThreadContext context)
|
IRubyObject |
getc()
Read a byte. |
IRubyObject |
getc19(ThreadContext context)
|
int |
getcCommon()
|
java.nio.channels.Channel |
getChannel()
|
ChannelDescriptor |
getDescriptorByFileno(int aFileno)
Deprecated. |
Stream |
getHandler()
Deprecated. |
java.io.InputStream |
getInStream()
|
static ModeFlags |
getIOModes(Ruby runtime,
java.lang.String modesString)
|
static int |
getIOModesIntFromString(Ruby runtime,
java.lang.String modesString)
|
IRubyObject |
getline(Ruby runtime,
org.jruby.util.ByteList separator)
|
IRubyObject |
getline(Ruby runtime,
org.jruby.util.ByteList separator,
long limit)
getline using logic of gets. |
int |
getNativeTypeIndex()
This is overridden in the other concrete Java builtins to provide a fast way
to determine what type they are. |
static int |
getNewFileno()
Deprecated. |
OpenFile |
getOpenFile()
|
protected OpenFile |
getOpenFileChecked()
|
java.io.OutputStream |
getOutStream()
|
IRubyObject |
gets(ThreadContext context)
Read a line. |
IRubyObject |
gets(ThreadContext context,
IRubyObject separatorArg)
|
IRubyObject |
gets(ThreadContext context,
IRubyObject[] args)
Deprecated. |
IRubyObject |
gets19(ThreadContext context)
|
IRubyObject |
gets19(ThreadContext context,
IRubyObject arg)
|
IRubyObject |
gets19(ThreadContext context,
IRubyObject separator,
IRubyObject limit_arg)
|
IRubyObject |
initialize_copy(IRubyObject original)
rb_obj_init_copy
Initializes this object as a copy of the original, that is the
parameter to this object. |
IRubyObject |
initialize(IRubyObject[] args,
Block unusedBlock)
|
IRubyObject |
initialize19(ThreadContext context,
IRubyObject fileNumber,
Block unusedBlock)
|
IRubyObject |
initialize19(ThreadContext context,
IRubyObject fileNumber,
IRubyObject second,
Block unusedBlock)
|
IRubyObject |
initialize19(ThreadContext context,
IRubyObject fileNumber,
IRubyObject modeValue,
IRubyObject options,
Block unusedBlock)
|
IRubyObject |
internal_encoding(ThreadContext context)
|
protected void |
interruptBlockingThreads()
Fire an IOError in all threads blocking on this IO object |
IRubyObject |
ioctl(ThreadContext context,
IRubyObject[] args)
|
boolean |
isAutoclose()
|
boolean |
isClosed()
Is this IO closed |
RubyFixnum |
lineno_set(ThreadContext context,
IRubyObject newLineNumber)
Sets the current line number. |
RubyFixnum |
lineno(ThreadContext context)
Returns the current line number. |
IRubyObject |
lines(ThreadContext context,
Block block)
|
IRubyObject |
lines19(ThreadContext context,
Block block)
|
static IRubyObject |
newInstance(ThreadContext context,
IRubyObject recv,
IRubyObject[] args,
Block block)
|
static RubyIO |
newIO(Ruby runtime,
java.nio.channels.Channel channel)
|
static void |
obliterateProcess(java.lang.Process process)
Try for around 1s to destroy the child process. |
IRubyObject |
op_append(ThreadContext context,
IRubyObject anObject)
rb_io_addstr |
IRubyObject |
op_binmode(ThreadContext context)
|
static IRubyObject |
open(ThreadContext context,
IRubyObject recv,
IRubyObject[] args,
Block block)
|
protected ModeFlags |
parseModes(IRubyObject arg)
|
protected ModeFlags |
parseModes19(ThreadContext context,
IRubyObject arg)
|
protected ModeFlags |
parseOptions(ThreadContext context,
IRubyObject options,
ModeFlags modes)
==== Options
opt can have the following keys
:mode ::
same as mode parameter
:external_encoding ::
external encoding for the IO. |
IRubyObject |
pid(ThreadContext context)
Return the process id (pid) of the process this IO object
spawned. |
static IRubyObject |
pipe(ThreadContext context,
IRubyObject recv)
|
static IRubyObject |
popen(ThreadContext context,
IRubyObject recv,
IRubyObject[] args,
Block block)
|
static IRubyObject |
popen19(ThreadContext context,
IRubyObject recv,
IRubyObject[] args,
Block block)
|
static IRubyObject |
popen3(ThreadContext context,
IRubyObject recv,
IRubyObject[] args,
Block block)
|
static IRubyObject |
popen4(ThreadContext context,
IRubyObject recv,
IRubyObject[] args,
Block block)
|
static org.jruby.RubyIO.POpenTuple |
popenSpecial(ThreadContext context,
IRubyObject[] args)
|
RubyFixnum |
pos_set(ThreadContext context,
IRubyObject newPosition)
|
RubyFixnum |
pos(ThreadContext context)
|
IRubyObject |
print(ThreadContext context,
IRubyObject[] args)
Print some objects to the stream. |
static IRubyObject |
print(ThreadContext context,
IRubyObject maybeIO,
IRubyObject[] args)
Print some objects to the stream. |
IRubyObject |
printf(ThreadContext context,
IRubyObject[] args)
|
IRubyObject |
putc(ThreadContext context,
IRubyObject object)
|
static IRubyObject |
putc(ThreadContext context,
IRubyObject maybeIO,
IRubyObject object)
|
IRubyObject |
puts(ThreadContext context,
IRubyObject[] args)
|
static IRubyObject |
puts(ThreadContext context,
IRubyObject maybeIO,
IRubyObject[] args)
|
IRubyObject |
read_nonblock(ThreadContext context,
IRubyObject[] args)
|
IRubyObject |
read(IRubyObject[] args)
|
IRubyObject |
read(ThreadContext context)
|
IRubyObject |
read(ThreadContext context,
IRubyObject arg0)
|
IRubyObject |
read(ThreadContext context,
IRubyObject arg0,
IRubyObject arg1)
|
static IRubyObject |
read(ThreadContext context,
IRubyObject recv,
IRubyObject[] args)
|
static IRubyObject |
read(ThreadContext context,
IRubyObject recv,
IRubyObject path,
Block unusedBlock)
Deprecated. |
static IRubyObject |
read(ThreadContext context,
IRubyObject recv,
IRubyObject path,
IRubyObject length)
Deprecated. |
static IRubyObject |
read(ThreadContext context,
IRubyObject recv,
IRubyObject path,
IRubyObject length,
IRubyObject offset)
Deprecated. |
static IRubyObject |
read19(ThreadContext context,
IRubyObject recv,
IRubyObject[] args,
Block unusedBlock)
|
protected RubyString |
readAll()
|
protected RubyString |
readAll(RubyString str)
|
protected org.jruby.util.ByteList |
readAllCommon(Ruby runtime)
|
IRubyObject |
readchar()
Read a byte. |
IRubyObject |
readchar19(ThreadContext context)
|
IRubyObject |
readline(ThreadContext context)
Read a line. |
IRubyObject |
readline(ThreadContext context,
IRubyObject separator)
|
IRubyObject |
readline(ThreadContext context,
IRubyObject[] args)
Deprecated. |
RubyArray |
readlines(ThreadContext context,
IRubyObject[] args)
|
static RubyArray |
readlines(ThreadContext context,
IRubyObject recv,
IRubyObject[] args,
Block unusedBlock)
|
IRubyObject |
readpartial(ThreadContext context,
IRubyObject[] args)
|
static IRubyObject |
readStatic(ThreadContext context,
IRubyObject recv,
IRubyObject path)
|
static IRubyObject |
readStatic(ThreadContext context,
IRubyObject recv,
IRubyObject path,
IRubyObject length)
|
static IRubyObject |
readStatic(ThreadContext context,
IRubyObject recv,
IRubyObject path,
IRubyObject length,
IRubyObject offset)
|
void |
registerDescriptor(ChannelDescriptor descriptor)
Deprecated. |
void |
registerDescriptor(ChannelDescriptor descriptor,
boolean isRetained)
Deprecated. |
void |
removeBlockingThread(RubyThread thread)
Remove a thread from the list of blocking threads for this IO. |
IRubyObject |
reopen(ThreadContext context,
IRubyObject[] args)
|
protected void |
reopenIO(Ruby runtime,
RubyIO ios)
|
protected void |
reopenPath(Ruby runtime,
IRubyObject[] args)
|
static boolean |
restartSystemCall(java.lang.Exception e)
|
RubyFixnum |
rewind(ThreadContext context)
|
RubyFixnum |
seek(ThreadContext context,
IRubyObject arg0)
|
RubyFixnum |
seek(ThreadContext context,
IRubyObject[] args)
|
RubyFixnum |
seek(ThreadContext context,
IRubyObject arg0,
IRubyObject arg1)
|
static IRubyObject |
select_static(ThreadContext context,
Ruby runtime,
IRubyObject[] args)
|
static IRubyObject |
select(ThreadContext context,
IRubyObject recv,
IRubyObject[] args)
|
IRubyObject |
set_encoding(ThreadContext context,
IRubyObject encodingString)
|
IRubyObject |
set_encoding(ThreadContext context,
IRubyObject encodingString,
IRubyObject internalEncoding)
|
IRubyObject |
set_encoding(ThreadContext context,
IRubyObject encodingString,
IRubyObject internalEncoding,
IRubyObject options)
|
void |
setAutoclose(boolean autoclose)
|
IRubyObject |
stat(ThreadContext context)
|
protected boolean |
swallow(int term)
|
IRubyObject |
sync_set(IRubyObject newSync)
Sets the current sync mode. |
RubyBoolean |
sync(ThreadContext context)
Returns the current sync mode. |
static IRubyObject |
sysopen(IRubyObject recv,
IRubyObject[] args,
Block block)
|
static IRubyObject |
sysopen19(ThreadContext context,
IRubyObject recv,
IRubyObject[] args,
Block block)
|
IRubyObject |
sysread(ThreadContext context,
IRubyObject[] args)
|
RubyFixnum |
sysseek(ThreadContext context,
IRubyObject[] args)
|
IRubyObject |
syswrite(ThreadContext context,
IRubyObject obj)
|
RubyIO |
to_io()
|
java.lang.String |
toString()
The default toString method is just a wrapper that calls the
Ruby "to_s" method. |
static IRubyObject |
tryConvert(ThreadContext context,
IRubyObject recv,
IRubyObject arg)
|
RubyBoolean |
tty_p(ThreadContext context)
|
IRubyObject |
ungetc(IRubyObject number)
Pushes char represented by int back onto IOS. |
IRubyObject |
ungetc19(IRubyObject number)
|
void |
unregisterDescriptor(int aFileno)
Deprecated. |
IRubyObject |
write_nonblock(ThreadContext context,
IRubyObject obj)
|
protected void |
write(ThreadContext context,
org.jruby.util.ByteList byteList)
|
IRubyObject |
write(ThreadContext context,
IRubyObject obj)
io_write |
protected static void |
write(ThreadContext context,
IRubyObject maybeIO,
org.jruby.util.ByteList byteList)
|
boolean |
writeDataBuffered()
Deprecated. |
Methods inherited from class org.jruby.RubyObject |
attachToObjectSpace, callInit, callInit, callInit, callInit, callInit, convertToType, createObjectClass, eqlInternal, equalInternal, equals, hashCode, initialize, op_eqq, puts, specificEval |
Methods inherited from class org.jruby.RubyBasicObject |
addFinalizer, anyToString, asJavaString, asString, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callSuper, checkArrayType, checkCallMethod, checkFrozen, checkStringType, checkStringType19, compareTo, convertToArray, convertToFloat, convertToHash, convertToInteger, convertToInteger, convertToInteger, convertToString, copyInstanceVariablesInto, copySpecialInstanceVariables, createBasicObjectClass, dataGetStruct, dataGetStructChecked, dataWrapStruct, display, dup, ensureInstanceVariablesSettable, eql_p, eql, equal_p, equal_p19, evalUnder, extend, fastGetInstanceVariable, fastGetInternalVariable, fastHasInstanceVariable, fastHasInternalVariable, fastSetInstanceVariable, fastSetInternalVariable, freeze, frozen_p, getFlag, getInstanceEvalClass, getInstanceVariable, getInstanceVariableList, getInstanceVariableNameList, getInstanceVariables, getInternalVariable, getInternalVariables, getJavaClass, getMetaClass, getObjectId, getRuntime, getSingletonClass, getSingletonClassClone, getType, getVariable, getVariableCount, getVariableList, getVariableNameList, hash, hashyInspect, hasInstanceVariable, hasInternalVariable, hasVariables, id_deprecated, id, infectBy, initialize19, initialize19, initialize19, initialize19, initialize19, initObjectId, inspect, inspectHashCode, instance_eval, instance_eval, instance_eval, instance_eval, instance_eval19, instance_eval19, instance_eval19, instance_eval19, instance_exec, instance_exec19, instance_of_p, instance_variable_defined_p, instance_variable_get, instance_variable_set, instance_variables, instance_variables19, isBuiltin, isClass, isFalse, isFrozen, isImmediate, isModule, isNil, isTaint, isTrue, isUntrusted, kind_of_p, makeMetaClass, method_missing19, method, method19, methods, methods, methods19, nil_p, op_cmp, op_equal_19, op_equal, op_match, op_match19, op_not_equal, op_not_match, op_not, private_methods, private_methods19, protected_methods, protected_methods19, public_methods, public_methods19, rbClone, remove_instance_variable, removeFinalizers, removeInstanceVariable, removeInternalVariable, respond_to_p, respond_to_p, respond_to_p19, respond_to_p19, respondsTo, respondsToMissing, respondsToMissing, send, send, send, send, send, send19, send19, send19, send19, send19, setFlag, setFrozen, setInstanceVariable, setInternalVariable, setMetaClass, setTaint, setUntrusted, setVariable, singleton_method_added19, singleton_method_removed19, singleton_method_undefined19, singleton_methods, singleton_methods19, specificEval, specificEval, specificEval, specificEval, syncVariables, syncVariables, taint, taint, tainted_p, testFrozen, testFrozen, to_a, to_s, toJava, trust, type_deprecated, type, untaint, untrust, untrusted_p, validateInstanceVariable, variableTableContains, variableTableFastContains, variableTableFastFetch, variableTableFastStore, variableTableFetch, variableTableRemove, variableTableStore, variableTableSync, yieldUnder, yieldUnder |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
openFile
protected OpenFile openFile
blockingThreads
protected java.util.List<RubyThread> blockingThreads
externalEncoding
protected org.jcodings.Encoding externalEncoding
internalEncoding
protected org.jcodings.Encoding internalEncoding
RubyIO
public RubyIO(Ruby runtime,
RubyClass type)
RubyIO
public RubyIO(Ruby runtime,
java.io.OutputStream outputStream)
RubyIO
public RubyIO(Ruby runtime,
java.io.InputStream inputStream)
RubyIO
public RubyIO(Ruby runtime,
java.nio.channels.Channel channel)
RubyIO
public RubyIO(Ruby runtime,
ShellLauncher.POpenProcess process,
ModeFlags modes)
RubyIO
public RubyIO(Ruby runtime,
STDIO stdio)
newIO
public static RubyIO newIO(Ruby runtime,
java.nio.channels.Channel channel)
getOpenFile
public OpenFile getOpenFile()
getOpenFileChecked
protected OpenFile getOpenFileChecked()
getNativeTypeIndex
public int getNativeTypeIndex()
- Description copied from class:
RubyObject
- This 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:
getNativeTypeIndex
in interface CoreObjectType
- Overrides:
getNativeTypeIndex
in class RubyObject
- Returns:
- the ClassIndex of the native type this object was constructed from
- See Also:
org.jruby.runtime.ClassInde
createIOClass
public static RubyClass createIOClass(Ruby runtime)
getOutStream
public java.io.OutputStream getOutStream()
getInStream
public java.io.InputStream getInStream()
getChannel
public java.nio.channels.Channel getChannel()
getHandler
@Deprecated
public Stream getHandler()
throws BadDescriptorException
- Deprecated.
- Throws:
BadDescriptorException
reopenPath
protected void reopenPath(Ruby runtime,
IRubyObject[] args)
reopenIO
protected void reopenIO(Ruby runtime,
RubyIO ios)
reopen
public IRubyObject reopen(ThreadContext context,
IRubyObject[] args)
getIOModes
public static ModeFlags getIOModes(Ruby runtime,
java.lang.String modesString)
throws InvalidValueException
- Throws:
InvalidValueException
getIOModesIntFromString
public static int getIOModesIntFromString(Ruby runtime,
java.lang.String modesString)
getline
public IRubyObject getline(Ruby runtime,
org.jruby.util.ByteList separator)
getline
public IRubyObject getline(Ruby runtime,
org.jruby.util.ByteList separator,
long limit)
- getline using logic of gets. If limit is -1 then read unlimited amount.
swallow
protected boolean swallow(int term)
throws java.io.IOException,
BadDescriptorException
- Throws:
java.io.IOException
BadDescriptorException
restartSystemCall
public static boolean restartSystemCall(java.lang.Exception e)
newInstance
public static IRubyObject newInstance(ThreadContext context,
IRubyObject recv,
IRubyObject[] args,
Block block)
initialize19
public IRubyObject initialize19(ThreadContext context,
IRubyObject fileNumber,
Block unusedBlock)
initialize19
public IRubyObject initialize19(ThreadContext context,
IRubyObject fileNumber,
IRubyObject second,
Block unusedBlock)
initialize19
public IRubyObject initialize19(ThreadContext context,
IRubyObject fileNumber,
IRubyObject modeValue,
IRubyObject options,
Block unusedBlock)
parseModes
protected ModeFlags parseModes(IRubyObject arg)
parseModes19
protected ModeFlags parseModes19(ThreadContext context,
IRubyObject arg)
initialize
public IRubyObject initialize(IRubyObject[] args,
Block unusedBlock)
fdopen
protected Stream fdopen(ChannelDescriptor existingDescriptor,
ModeFlags modes)
throws InvalidValueException
- Throws:
InvalidValueException
external_encoding
public IRubyObject external_encoding(ThreadContext context)
internal_encoding
public IRubyObject internal_encoding(ThreadContext context)
set_encoding
public IRubyObject set_encoding(ThreadContext context,
IRubyObject encodingString)
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)
open
public static IRubyObject open(ThreadContext context,
IRubyObject recv,
IRubyObject[] args,
Block block)
sysopen
public static IRubyObject sysopen(IRubyObject recv,
IRubyObject[] args,
Block block)
sysopen19
public static IRubyObject sysopen19(ThreadContext context,
IRubyObject recv,
IRubyObject[] args,
Block block)
isAutoclose
public boolean isAutoclose()
setAutoclose
public void setAutoclose(boolean autoclose)
autoclose
public IRubyObject autoclose(ThreadContext context)
autoclose_set
public IRubyObject autoclose_set(ThreadContext context,
IRubyObject autoclose)
binmode
public IRubyObject binmode()
op_binmode
public IRubyObject op_binmode(ThreadContext context)
syswrite
public IRubyObject syswrite(ThreadContext context,
IRubyObject obj)
write_nonblock
public IRubyObject write_nonblock(ThreadContext context,
IRubyObject obj)
write
public IRubyObject write(ThreadContext context,
IRubyObject obj)
- io_write
fwrite
protected int fwrite(org.jruby.util.ByteList buffer)
op_append
public IRubyObject op_append(ThreadContext context,
IRubyObject anObject)
- rb_io_addstr
fileno
public RubyFixnum fileno(ThreadContext context)
lineno
public RubyFixnum lineno(ThreadContext context)
- Returns the current line number.
- Returns:
- the current line number.
lineno_set
public RubyFixnum lineno_set(ThreadContext context,
IRubyObject newLineNumber)
- Sets the current line number.
- Parameters:
newLineNumber
- The new line number.
sync
public RubyBoolean sync(ThreadContext context)
- Returns the current sync mode.
- Returns:
- the current sync mode.
pid
public IRubyObject pid(ThreadContext context)
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
public RubyFixnum pos(ThreadContext context)
pos_set
public RubyFixnum pos_set(ThreadContext context,
IRubyObject newPosition)
print
public IRubyObject print(ThreadContext context,
IRubyObject[] args)
- Print some objects to the stream.
print
public static IRubyObject print(ThreadContext context,
IRubyObject maybeIO,
IRubyObject[] args)
- Print some objects to the stream.
printf
public IRubyObject printf(ThreadContext context,
IRubyObject[] args)
putc
public IRubyObject putc(ThreadContext context,
IRubyObject object)
putc
public static IRubyObject putc(ThreadContext context,
IRubyObject maybeIO,
IRubyObject object)
seek
public RubyFixnum seek(ThreadContext context,
IRubyObject[] args)
seek
public RubyFixnum seek(ThreadContext context,
IRubyObject arg0)
seek
public RubyFixnum seek(ThreadContext context,
IRubyObject arg0,
IRubyObject arg1)
sysseek
public RubyFixnum sysseek(ThreadContext context,
IRubyObject[] args)
rewind
public RubyFixnum rewind(ThreadContext context)
fsync
public RubyFixnum fsync(ThreadContext context)
sync_set
public IRubyObject sync_set(IRubyObject newSync)
- Sets the current sync mode.
- Parameters:
newSync
- The new sync mode.
eof_p
public RubyBoolean eof_p(ThreadContext context)
tty_p
public RubyBoolean tty_p(ThreadContext context)
initialize_copy
public IRubyObject initialize_copy(IRubyObject original)
- Description copied from class:
RubyBasicObject
- rb_obj_init_copy
Initializes 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_copy
in class RubyBasicObject
closed_p
public RubyBoolean closed_p(ThreadContext context)
isClosed
public boolean isClosed()
- Is this IO closed
- Returns:
- true if closed
close
public IRubyObject close()
Closes all open resources for the IO. It also removes
it from our magical all open file descriptor pool.
- Returns:
- The IO.
close2
protected IRubyObject close2(Ruby runtime)
close_write
public IRubyObject close_write(ThreadContext context)
close_read
public IRubyObject close_read(ThreadContext context)
flush
public RubyIO flush()
- Flushes the IO output stream.
- Returns:
- The IO.
gets
public IRubyObject gets(ThreadContext context)
- Read a line.
gets
public IRubyObject gets(ThreadContext context,
IRubyObject separatorArg)
gets19
public IRubyObject gets19(ThreadContext context)
gets19
public IRubyObject gets19(ThreadContext context,
IRubyObject arg)
gets19
public IRubyObject gets19(ThreadContext context,
IRubyObject separator,
IRubyObject limit_arg)
getBlocking
public boolean getBlocking()
fcntl
public IRubyObject fcntl(ThreadContext context,
IRubyObject cmd)
fcntl
public IRubyObject fcntl(ThreadContext context,
IRubyObject cmd,
IRubyObject arg)
ioctl
public IRubyObject ioctl(ThreadContext context,
IRubyObject[] args)
ctl
public IRubyObject ctl(Ruby runtime,
IRubyObject cmd,
IRubyObject arg)
puts
public IRubyObject puts(ThreadContext context,
IRubyObject[] args)
puts
public static IRubyObject puts(ThreadContext context,
IRubyObject maybeIO,
IRubyObject[] args)
write
protected void write(ThreadContext context,
org.jruby.util.ByteList byteList)
write
protected static void write(ThreadContext context,
IRubyObject maybeIO,
org.jruby.util.ByteList byteList)
readline
public IRubyObject readline(ThreadContext context)
- Read a line.
readline
public IRubyObject readline(ThreadContext context,
IRubyObject separator)
getc
public IRubyObject getc()
- Read a byte. On EOF returns nil.
readchar19
public IRubyObject readchar19(ThreadContext context)
getbyte19
public IRubyObject getbyte19(ThreadContext context)
getc19
public IRubyObject getc19(ThreadContext context)
getcCommon
public int getcCommon()
ungetc
public IRubyObject ungetc(IRubyObject number)
Pushes char represented by int back onto IOS.
- Parameters:
number
- to push back
ungetc19
public IRubyObject ungetc19(IRubyObject number)
read_nonblock
public IRubyObject read_nonblock(ThreadContext context,
IRubyObject[] args)
readpartial
public IRubyObject readpartial(ThreadContext context,
IRubyObject[] args)
sysread
public IRubyObject sysread(ThreadContext context,
IRubyObject[] args)
read
public IRubyObject read(IRubyObject[] args)
read
public IRubyObject read(ThreadContext context)
read
public IRubyObject read(ThreadContext context,
IRubyObject arg0)
read
public IRubyObject read(ThreadContext context,
IRubyObject arg0,
IRubyObject arg1)
emptyBufferOrEOF
protected static boolean emptyBufferOrEOF(org.jruby.util.ByteList buffer,
OpenFile myOpenFile)
throws BadDescriptorException,
java.io.IOException
- Throws:
BadDescriptorException
java.io.IOException
readAll
protected RubyString readAll(RubyString str)
throws BadDescriptorException,
java.io.EOFException,
java.io.IOException
- Throws:
BadDescriptorException
java.io.EOFException
java.io.IOException
readAll
protected RubyString readAll()
throws BadDescriptorException,
java.io.EOFException,
java.io.IOException
- Throws:
BadDescriptorException
java.io.EOFException
java.io.IOException
readAllCommon
protected org.jruby.util.ByteList readAllCommon(Ruby runtime)
throws BadDescriptorException,
java.io.EOFException,
java.io.IOException
- Throws:
BadDescriptorException
java.io.EOFException
java.io.IOException
readchar
public IRubyObject readchar()
- Read a byte. On EOF throw EOFError.
stat
public IRubyObject stat(ThreadContext context)
each_byteInternal
public IRubyObject each_byteInternal(ThreadContext context,
Block block)
Invoke a block for each byte.
each_byte
public IRubyObject each_byte(ThreadContext context,
Block block)
bytes
public IRubyObject bytes(ThreadContext context)
lines
public IRubyObject lines(ThreadContext context,
Block block)
lines19
public IRubyObject lines19(ThreadContext context,
Block block)
each_charInternal
public IRubyObject each_charInternal(ThreadContext context,
Block block)
each_char
public IRubyObject each_char(ThreadContext context,
Block block)
chars
public IRubyObject chars(ThreadContext context,
Block block)
codepoints
public IRubyObject codepoints(ThreadContext context,
Block block)
each_codepoint
public IRubyObject each_codepoint(ThreadContext context,
Block block)
each_lineInternal
public RubyIO each_lineInternal(ThreadContext context,
IRubyObject[] args,
Block block)
Invoke a block for each line.
each
public IRubyObject each(ThreadContext context,
IRubyObject[] args,
Block block)
each_line
public IRubyObject each_line(ThreadContext context,
IRubyObject[] args,
Block block)
readlines
public RubyArray readlines(ThreadContext context,
IRubyObject[] args)
to_io
public RubyIO to_io()
toString
public java.lang.String toString()
- Description copied from class:
RubyObject
- The default toString method is just a wrapper that calls the
Ruby "to_s" method.
- Overrides:
toString
in class RubyObject
foreachInternal
public static IRubyObject foreachInternal(ThreadContext context,
IRubyObject recv,
IRubyObject[] args,
Block block)
- rb_io_s_foreach
foreachInternal19
public static IRubyObject foreachInternal19(ThreadContext context,
IRubyObject recv,
IRubyObject[] args,
Block block)
- rb_io_s_foreach
foreach
public static IRubyObject foreach(ThreadContext context,
IRubyObject recv,
IRubyObject[] args,
Block block)
foreach19
public static IRubyObject foreach19(ThreadContext context,
IRubyObject recv,
IRubyObject[] args,
Block block)
convertToIO
public static RubyIO convertToIO(ThreadContext context,
IRubyObject obj)
select
public static IRubyObject select(ThreadContext context,
IRubyObject recv,
IRubyObject[] args)
select_static
public static IRubyObject select_static(ThreadContext context,
Ruby runtime,
IRubyObject[] args)
read
public static IRubyObject read(ThreadContext context,
IRubyObject recv,
IRubyObject[] args)
failIfDirectory
public static void failIfDirectory(Ruby runtime,
RubyString pathStr)
read
@Deprecated
public static IRubyObject read(ThreadContext context,
IRubyObject recv,
IRubyObject path,
Block unusedBlock)
- Deprecated.
read
@Deprecated
public static IRubyObject read(ThreadContext context,
IRubyObject recv,
IRubyObject path,
IRubyObject length)
- Deprecated.
read
@Deprecated
public static IRubyObject read(ThreadContext context,
IRubyObject recv,
IRubyObject path,
IRubyObject length,
IRubyObject offset)
- Deprecated.
readStatic
public static IRubyObject readStatic(ThreadContext context,
IRubyObject recv,
IRubyObject path)
readStatic
public static IRubyObject readStatic(ThreadContext context,
IRubyObject recv,
IRubyObject path,
IRubyObject length)
readStatic
public static IRubyObject readStatic(ThreadContext context,
IRubyObject recv,
IRubyObject path,
IRubyObject length,
IRubyObject offset)
binread
public static IRubyObject binread(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"
- 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
read19
public static IRubyObject read19(ThreadContext context,
IRubyObject recv,
IRubyObject[] args,
Block unusedBlock)
readlines
public static RubyArray readlines(ThreadContext context,
IRubyObject recv,
IRubyObject[] args,
Block unusedBlock)
popen
public static IRubyObject popen(ThreadContext context,
IRubyObject recv,
IRubyObject[] args,
Block block)
popen19
public static IRubyObject popen19(ThreadContext context,
IRubyObject recv,
IRubyObject[] args,
Block block)
popen3
public static IRubyObject popen3(ThreadContext context,
IRubyObject recv,
IRubyObject[] args,
Block block)
popen4
public static IRubyObject popen4(ThreadContext context,
IRubyObject recv,
IRubyObject[] args,
Block block)
popenSpecial
public static org.jruby.RubyIO.POpenTuple popenSpecial(ThreadContext context,
IRubyObject[] args)
pipe
public static IRubyObject pipe(ThreadContext context,
IRubyObject recv)
copy_stream
public static IRubyObject copy_stream(ThreadContext context,
IRubyObject recv,
IRubyObject arg1,
IRubyObject arg2)
tryConvert
public static IRubyObject tryConvert(ThreadContext context,
IRubyObject recv,
IRubyObject arg)
addBlockingThread
public void addBlockingThread(RubyThread thread)
- Add a thread to the list of blocking threads for this IO.
- Parameters:
thread
- A thread blocking on this IO
removeBlockingThread
public void removeBlockingThread(RubyThread thread)
- Remove a thread from the list of blocking threads for this IO.
- Parameters:
thread
- A thread blocking on this IO
interruptBlockingThreads
protected void interruptBlockingThreads()
- Fire an IOError in all threads blocking on this IO object
parseOptions
protected ModeFlags parseOptions(ThreadContext context,
IRubyObject options,
ModeFlags modes)
- ==== Options
opt
can have the following keys
:mode ::
same as mode
parameter
:external_encoding ::
external encoding for the IO. "-" is a
synonym for the default external encoding.
:internal_encoding ::
internal encoding for the IO.
"-" is a synonym for the default internal encoding.
If the value is nil no conversion occurs.
:encoding ::
specifies external and internal encodings as "extern:intern".
:textmode ::
If the value is truth value, same as "b" in argument mode
.
:binmode ::
If the value is truth value, same as "t" in argument mode
.
Also opt
can have same keys in String#encode
for
controlling conversion between the external encoding and the internal encoding.
obliterateProcess
public static void obliterateProcess(java.lang.Process process)
- 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:
runtime
- The Ruby runtime, for raising an errorprocess
- The process to obliterate
registerDescriptor
@Deprecated
public void registerDescriptor(ChannelDescriptor descriptor,
boolean isRetained)
- Deprecated.
registerDescriptor
@Deprecated
public void registerDescriptor(ChannelDescriptor descriptor)
- Deprecated.
unregisterDescriptor
@Deprecated
public void unregisterDescriptor(int aFileno)
- Deprecated.
getDescriptorByFileno
@Deprecated
public ChannelDescriptor getDescriptorByFileno(int aFileno)
- Deprecated.
getNewFileno
@Deprecated
public static int getNewFileno()
- Deprecated.
writeDataBuffered
@Deprecated
public boolean writeDataBuffered()
- Deprecated.
gets
@Deprecated
public IRubyObject gets(ThreadContext context,
IRubyObject[] args)
- Deprecated.
readline
@Deprecated
public IRubyObject readline(ThreadContext context,
IRubyObject[] args)
- Deprecated.
Copyright © 2002-2009 JRuby Team. All Rights Reserved.