Class: Clevic::Stream
- Includes:
- IO::Like
- Defined in:
- lib/clevic/swing/clipboard.rb
Overview
Wrapper for java.io.InputStream to make it nicer for Ruby
Instance Method Summary collapse
-
#initialize(input_stream) ⇒ Stream
constructor
A new instance of Stream.
- #unbuffered_read(length) ⇒ Object
Constructor Details
#initialize(input_stream) ⇒ Stream
Returns a new instance of Stream.
24 25 26 |
# File 'lib/clevic/swing/clipboard.rb', line 24 def initialize( input_stream ) @input_stream = input_stream end |
Instance Method Details
#unbuffered_read(length) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/clevic/swing/clipboard.rb', line 29 def unbuffered_read( length ) nex = @input_stream.read raise EOFError if nex == -1 begin (0...length).inject([nex]) do |buf,i| nex = @input_stream.read if nex == -1 break( buf ) else buf << nex end end.pack('c*') rescue raise SystemCallError, $!. end end |