Class: PipeDream
- Inherits:
-
Object
- Object
- PipeDream
- Defined in:
- lib/multitest/pipe_dream.rb
Instance Method Summary collapse
- #close ⇒ Object
- #done_reading ⇒ Object
- #done_writing ⇒ Object
- #eof? ⇒ Boolean
- #gets ⇒ Object
- #identify_as_child ⇒ Object
- #identify_as_parent ⇒ Object
-
#initialize ⇒ PipeDream
constructor
A new instance of PipeDream.
- #write(str) ⇒ Object
Constructor Details
#initialize ⇒ PipeDream
Returns a new instance of PipeDream.
2 3 4 5 |
# File 'lib/multitest/pipe_dream.rb', line 2 def initialize @child_read, @parent_write = IO.pipe @parent_read, @child_write = IO.pipe end |
Instance Method Details
#close ⇒ Object
35 36 37 38 |
# File 'lib/multitest/pipe_dream.rb', line 35 def close done_reading done_writing end |
#done_reading ⇒ Object
44 45 46 |
# File 'lib/multitest/pipe_dream.rb', line 44 def done_reading @reader.close unless @reader.closed? end |
#done_writing ⇒ Object
40 41 42 |
# File 'lib/multitest/pipe_dream.rb', line 40 def done_writing @writer.close unless @writer.closed? end |
#eof? ⇒ Boolean
17 18 19 |
# File 'lib/multitest/pipe_dream.rb', line 17 def eof? @reader.eof? end |
#gets ⇒ Object
7 8 9 |
# File 'lib/multitest/pipe_dream.rb', line 7 def gets @reader.gets end |
#identify_as_child ⇒ Object
21 22 23 24 25 26 |
# File 'lib/multitest/pipe_dream.rb', line 21 def identify_as_child @parent_write.close @parent_read.close @reader = @child_read @writer = @child_write end |
#identify_as_parent ⇒ Object
28 29 30 31 32 33 |
# File 'lib/multitest/pipe_dream.rb', line 28 def identify_as_parent @child_write.close @child_read.close @reader = @parent_read @writer = @parent_write end |
#write(str) ⇒ Object
11 12 13 14 15 |
# File 'lib/multitest/pipe_dream.rb', line 11 def write(str) @writer.write(str) @writer.flush str end |