Class: PVC::WithErrPiece::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/pvc/with_err_piece.rb

Instance Method Summary collapse

Constructor Details

#initializeRunner

Returns a new instance of Runner.



5
6
7
8
9
10
11
12
# File 'lib/pvc/with_err_piece.rb', line 5

def initialize
  @stdread, @stdwrite = IO.pipe
  @errread, @errwrite = IO.pipe
  @stdread.close_on_exec = true
  @stdwrite.close_on_exec = true
  @errread.close_on_exec = true
  @errwrite.close_on_exec = true
end

Instance Method Details

#errinObject



18
19
20
# File 'lib/pvc/with_err_piece.rb', line 18

def errin
  @errwrite
end

#finishObject



31
32
33
34
35
36
37
38
# File 'lib/pvc/with_err_piece.rb', line 31

def finish
  @stdwrite.close
  @errwrite.close
  @stdthread.join
  @errthread.join
  @stdread.close
  @errread.close
end

#start(following_piece) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/pvc/with_err_piece.rb', line 22

def start(following_piece)
  @stdthread = Thread.new do
    @stdread.each_line { |line| following_piece.stdin.puts line }
  end
  @errthread = Thread.new do
    @errread.each_line { |line| following_piece.stdin.puts line }
  end
end

#stdinObject



14
15
16
# File 'lib/pvc/with_err_piece.rb', line 14

def stdin
  @stdwrite
end