Package org.jruby.util
Class IOOutputStream
java.lang.Object
java.io.OutputStream
org.jruby.util.IOOutputStream
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
This class wraps a IRubyObject in an OutputStream. Depending on which messages
the IRubyObject answers to, it will have different functionality.
The point is that the IRubyObject could exhibit duck typing, in the style of IO versus StringIO, for example.
At the moment, the only functionality supported is writing, and the only requirement on the io-object is
that it responds to write() and close() like IO.
- Author:
- Ola Bini
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new OutputStream with the object provided.IOOutputStream
(IRubyObject io, boolean checkAppend, boolean verifyCanWrite) IOOutputStream
(IRubyObject io, org.jcodings.Encoding encoding) IOOutputStream
(IRubyObject io, org.jcodings.Encoding encoding, boolean checkAppend, boolean verifyCanWrite) Creates a new OutputStream with the object provided. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
protected boolean
fastWritable
(RubyIO io) protected RubyIO
getRealIO
(IRubyObject io) void
write
(byte[] b) void
write
(byte[] b, int off, int len) void
write
(int bite) Methods inherited from class java.io.OutputStream
flush, nullOutputStream
-
Constructor Details
-
IOOutputStream
public IOOutputStream(IRubyObject io, org.jcodings.Encoding encoding, boolean checkAppend, boolean verifyCanWrite) Creates a new OutputStream with the object provided.- Parameters:
io
- the ruby object
-
IOOutputStream
-
IOOutputStream
Creates a new OutputStream with the object provided.- Parameters:
io
- the ruby object
-
IOOutputStream
-
-
Method Details
-
getRealIO
-
fastWritable
-
write
- Specified by:
write
in classOutputStream
- Throws:
IOException
-
write
- Overrides:
write
in classOutputStream
- Throws:
IOException
-
write
- Overrides:
write
in classOutputStream
- Throws:
IOException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classOutputStream
- Throws:
IOException
-