Class: ChildProcess::JRuby::Redirector
- Inherits:
-
Object
- Object
- ChildProcess::JRuby::Redirector
- Defined in:
- lib/childprocess/jruby/redirector.rb
Constant Summary collapse
- BUFFER_SIZE =
2048
Instance Method Summary collapse
-
#initialize(input, output) ⇒ Redirector
constructor
A new instance of Redirector.
- #run ⇒ Object
Constructor Details
#initialize(input, output) ⇒ Redirector
Returns 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
#run ⇒ Object
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 |