Class: ChildProcess::JRuby::Redirector
- Inherits:
-
Object
- Object
- ChildProcess::JRuby::Redirector
- Defined in:
- lib/childprocess/jruby/redirector.rb
Constant Summary
- BUFFER_SIZE =
2048
Instance Method Summary (collapse)
-
- (Redirector) initialize(input, output)
constructor
A new instance of Redirector.
- - (Object) run
Constructor Details
- (Redirector) initialize(input, output)
A new instance of Redirector
6 7 8 9 10 |
# File 'lib/childprocess/jruby/redirector.rb', line 6 def initialize(input, output) @input = input @output = output @buffer = Java.byte[BUFFER_SIZE].new end |
Instance Method Details
- (Object) run
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/childprocess/jruby/redirector.rb', line 12 def run read, avail = 0, 0 while(read != -1) avail = [@input.available, 1].max read = @input.read(@buffer, 0, avail) if read > 0 @output.write(@buffer, 0, read) end end rescue java.io.IOException => ex $stderr.puts ex., ex.backtrace if $DEBUG end |