Class: PVC::WithErrPiece::Runner
- Inherits:
-
Object
- Object
- PVC::WithErrPiece::Runner
- Defined in:
- lib/pvc/with_err_piece.rb
Instance Method Summary collapse
- #errin ⇒ Object
- #finish ⇒ Object
-
#initialize ⇒ Runner
constructor
A new instance of Runner.
- #start(following_piece) ⇒ Object
- #stdin ⇒ Object
Constructor Details
#initialize ⇒ Runner
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
#errin ⇒ Object
18 19 20 |
# File 'lib/pvc/with_err_piece.rb', line 18 def errin @errwrite end |
#finish ⇒ Object
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 |
#stdin ⇒ Object
14 15 16 |
# File 'lib/pvc/with_err_piece.rb', line 14 def stdin @stdwrite end |