class ChildProcess::JRuby::Redirector

Constants

BUFFER_SIZE

Public Class Methods

new(input, output) click to toggle source
# File lib/childprocess/jruby/redirector.rb, line 6
def initialize(input, output)
  @input = input
  @output = output
  @buffer = Java.byte[BUFFER_SIZE].new
end

Public Instance Methods

run() click to toggle source
# 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.message, ex.backtrace if $DEBUG
end