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, 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 |
Method Summary |
void |
addBlockingThread(RubyThread thread)
Add a thread to the list of blocking threads for this IO. |
IRubyObject |
binmode()
|
IRubyObject |
bytes(ThreadContext context)
|
IRubyObject |
chars19(ThreadContext context,
Block block)
|
protected void |
checkClosed()
Deprecated. will be removed in 1.2 |
protected void |
checkInitialized()
Deprecated. will be removed in 1.2 |
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)
|
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)
Invoke a block for each byte. |
IRubyObject |
each_byte19(ThreadContext context,
Block block)
|
IRubyObject |
each_char(ThreadContext context,
Block block)
|
IRubyObject |
each_char19(ThreadContext context,
Block block)
|
RubyIO |
each_line(ThreadContext context,
IRubyObject[] args,
Block block)
Invoke a block for each line. |
IRubyObject |
each_line19(ThreadContext context,
IRubyObject[] args,
Block block)
|
IRubyObject |
each19(ThreadContext context,
IRubyObject[] args,
Block block)
|
RubyBoolean |
eof_p(ThreadContext context)
|
IRubyObject |
external_encoding(ThreadContext context)
|
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)
rb_io_s_foreach |
static IRubyObject |
foreach19(ThreadContext context,
IRubyObject recv,
IRubyObject[] args,
Block block)
|
RubyFixnum |
fsync(ThreadContext context)
|
protected int |
fwrite(org.jruby.util.ByteList buffer)
|
boolean |
getBlocking()
|
IRubyObject |
getc()
Read a byte. |
java.nio.channels.Channel |
getChannel()
|
ChannelDescriptor |
getDescriptorByFileno(int aFileno)
|
Stream |
getHandler()
|
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. |
IRubyObject |
getlineFast(Ruby runtime,
int delim)
|
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()
|
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 |
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)
|
static IRubyObject |
newInstance(ThreadContext context,
IRubyObject recv,
IRubyObject[] args,
Block block)
|
static RubyIO |
newIO(Ruby runtime,
java.nio.channels.Channel channel)
|
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 |
popen3(ThreadContext context,
IRubyObject recv,
IRubyObject[] args,
Block block)
|
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)
|
static IRubyObject |
read(ThreadContext context,
IRubyObject recv,
IRubyObject path,
IRubyObject length)
|
static IRubyObject |
read(ThreadContext context,
IRubyObject recv,
IRubyObject path,
IRubyObject length,
IRubyObject offset)
|
static IRubyObject |
read19(ThreadContext context,
IRubyObject recv,
IRubyObject[] args,
Block unusedBlock)
|
protected IRubyObject |
readAll(IRubyObject buffer)
|
IRubyObject |
readchar()
Read a byte. |
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)
|
void |
registerDescriptor(ChannelDescriptor descriptor)
|
void |
registerDescriptor(ChannelDescriptor descriptor,
boolean isRetained)
|
void |
removeBlockingThread(RubyThread thread)
Remove a thread from the list of blocking threads for this IO. |
IRubyObject |
reopen(ThreadContext context,
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)
|
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)
|
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. |
RubyBoolean |
tty_p(ThreadContext context)
|
IRubyObject |
ungetc(IRubyObject number)
Pushes char represented by int back onto IOS. |
void |
unregisterDescriptor(int aFileno)
|
protected boolean |
waitReadable(ChannelDescriptor descriptor)
|
protected boolean |
waitWritable(ChannelDescriptor descriptor)
|
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 |
as, attachToObjectSpace, callInit, checkFrozen, convertToType, createObjectClass, display, dup, eql_p, eqlInternal, equal_p, equalInternal, equals, evalUnder, evalUnder, extend, freeze, frozen_p, hash, hashCode, id_deprecated, id, initialize, inspect, 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, kind_of_p, method, methods, methods, methods19, nil_p, op_eqq, op_equal, op_match, op_not_match, private_methods, private_methods19, protected_methods, protected_methods19, public_methods, public_methods19, puts, rbClone, remove_instance_variable, respond_to_p, respond_to_p, send, send, send, send, send, singleton_methods, singleton_methods19, singletonMethods, specificEval, specificEval, specificEval, specificEval, specificEval, taint, tainted_p, to_a, to_java, to_s, trust, type_deprecated, type, untaint, untrust, untrusted_p, validateInstanceVariable |
Methods inherited from class org.jruby.RubyBasicObject |
addFinalizer, anyToString, asJavaString, asString, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callSuper, checkArrayType, checkStringType, compareTo, convertToArray, convertToFloat, convertToHash, convertToInteger, convertToInteger, convertToInteger, convertToString, copyInstanceVariablesInto, copySpecialInstanceVariables, createBasicObjectClass, dataGetStruct, dataGetStructChecked, dataWrapStruct, ensureInstanceVariablesSettable, eql, fastGetInstanceVariable, fastGetInternalVariable, fastHasInstanceVariable, fastHasInternalVariable, fastSetInstanceVariable, fastSetInternalVariable, getFlag, getInstanceVariable, getInstanceVariableList, getInstanceVariableNameList, getInstanceVariables, getInternalVariable, getInternalVariables, getJavaClass, getMetaClass, getRuntime, getSingletonClass, getSingletonClassClone, getType, getVariable, getVariableCount, getVariableList, getVariableNameList, hasInstanceVariable, hasInternalVariable, hasVariables, infectBy, isClass, isFalse, isFrozen, isImmediate, isModule, isNil, isTaint, isTrue, isUntrusted, makeMetaClass, op_not_equal, op_not, removeFinalizers, removeInstanceVariable, removeInternalVariable, respondsTo, setFlag, setFrozen, setInstanceVariable, setInternalVariable, setMetaClass, setTaint, setUntrusted, setVariable, syncVariables, taint, testFrozen, testFrozen, toJava, variableTableContains, variableTableFastContains, variableTableFastFetch, variableTableFastStore, variableTableFetch, variableTableGetSize, variableTableRemove, variableTableStore, variableTableSync |
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 IRubyObject externalEncoding
internalEncoding
protected IRubyObject internalEncoding
filenoIndex
protected static java.util.concurrent.atomic.AtomicInteger filenoIndex
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)
registerDescriptor
public void registerDescriptor(ChannelDescriptor descriptor,
boolean isRetained)
registerDescriptor
public void registerDescriptor(ChannelDescriptor descriptor)
unregisterDescriptor
public void unregisterDescriptor(int aFileno)
getDescriptorByFileno
public ChannelDescriptor getDescriptorByFileno(int aFileno)
getNewFileno
public static int getNewFileno()
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
public Stream getHandler()
reopen
public IRubyObject reopen(ThreadContext context,
IRubyObject[] args)
throws InvalidValueException
- Throws:
InvalidValueException
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)
getlineFast
public IRubyObject getlineFast(Ruby runtime,
int delim)
throws java.io.IOException,
BadDescriptorException
- Throws:
java.io.IOException
BadDescriptorException
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)
binmode
public IRubyObject binmode()
op_binmode
public IRubyObject op_binmode(ThreadContext context)
checkInitialized
protected void checkInitialized()
- Deprecated. will be removed in 1.2
checkClosed
protected void checkClosed()
- Deprecated. will be removed in 1.2
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
waitWritable
protected boolean waitWritable(ChannelDescriptor descriptor)
throws java.io.IOException
- Throws:
java.io.IOException
waitReadable
protected boolean waitReadable(ChannelDescriptor descriptor)
throws java.io.IOException
- Throws:
java.io.IOException
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
writeDataBuffered
public boolean writeDataBuffered()
- Deprecated.
- Returns:
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:
RubyObject
- 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 RubyObject
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)
throws BadDescriptorException
- Throws:
BadDescriptorException
close_read
public IRubyObject close_read(ThreadContext context)
throws BadDescriptorException
- Throws:
BadDescriptorException
flush
public RubyIO flush()
- Flushes the IO output stream.
- Returns:
- The IO.
gets
@Deprecated
public IRubyObject gets(ThreadContext context,
IRubyObject[] args)
- Deprecated.
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
@Deprecated
public IRubyObject readline(ThreadContext context,
IRubyObject[] args)
- Deprecated.
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.
ungetc
public IRubyObject ungetc(IRubyObject number)
Pushes char represented by int back onto IOS.
- Parameters:
number
- to push back
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)
readAll
protected IRubyObject readAll(IRubyObject buffer)
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_byte
public IRubyObject each_byte(ThreadContext context,
Block block)
Invoke a block for each byte.
each_byte19
public IRubyObject each_byte19(ThreadContext context,
Block block)
bytes
public IRubyObject bytes(ThreadContext context)
lines
public IRubyObject lines(ThreadContext context)
each_char
public IRubyObject each_char(ThreadContext context,
Block block)
each_char19
public IRubyObject each_char19(ThreadContext context,
Block block)
chars19
public IRubyObject chars19(ThreadContext context,
Block block)
each_line
public RubyIO each_line(ThreadContext context,
IRubyObject[] args,
Block block)
Invoke a block for each line.
each19
public IRubyObject each19(ThreadContext context,
IRubyObject[] args,
Block block)
each_line19
public IRubyObject each_line19(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
foreach
public static IRubyObject foreach(ThreadContext context,
IRubyObject recv,
IRubyObject[] args,
Block block)
- rb_io_s_foreach
foreach19
public static IRubyObject foreach19(ThreadContext context,
IRubyObject recv,
IRubyObject[] args,
Block block)
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)
read
public static IRubyObject read(ThreadContext context,
IRubyObject recv,
IRubyObject path,
Block unusedBlock)
read
public static IRubyObject read(ThreadContext context,
IRubyObject recv,
IRubyObject path,
IRubyObject length)
read
public static IRubyObject read(ThreadContext context,
IRubyObject recv,
IRubyObject path,
IRubyObject length,
IRubyObject 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)
popen3
public static IRubyObject popen3(ThreadContext context,
IRubyObject recv,
IRubyObject[] args,
Block block)
pipe
public static IRubyObject pipe(ThreadContext context,
IRubyObject recv)
throws java.lang.Exception
- Throws:
java.lang.Exception
copy_stream
public static IRubyObject copy_stream(ThreadContext context,
IRubyObject recv,
IRubyObject arg1,
IRubyObject arg2)
throws java.io.IOException
- Throws:
java.io.IOException
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.
Copyright © 2002-2009 JRuby Team. All Rights Reserved.