Class: IOPipe
Overview
- Author
-
Nicolas Pouillard <[email protected]>.
- Copyright
-
Copyright © 2005, 2006 Nicolas Pouillard. All rights reserved.
- License
-
GNU General Public License (GPL).
- Revision
-
$Id: /w/fey/cmd/trunk/lib/objective_command/datas/pipe.rb 24389 2006-07-09T20:37:31.813443Z ertai $
Instance Attribute Summary collapse
-
#open_mode ⇒ Object
Returns the value of attribute open_mode.
-
#reader ⇒ Object
Returns the value of attribute reader.
-
#writer ⇒ Object
Returns the value of attribute writer.
Instance Method Summary collapse
- #close ⇒ Object (also: #clean)
- #each_line(&block) ⇒ Object
-
#initialize ⇒ IOPipe
constructor
A new instance of IOPipe.
- #open(mode = :r) ⇒ Object
- #read ⇒ Object
- #to_io_for_ocmd ⇒ Object
Constructor Details
Instance Attribute Details
#open_mode ⇒ Object
Returns the value of attribute open_mode.
7 8 9 |
# File 'lib/objective_command/datas/pipe.rb', line 7 def open_mode @open_mode end |
#reader ⇒ Object
Returns the value of attribute reader.
7 8 9 |
# File 'lib/objective_command/datas/pipe.rb', line 7 def reader @reader end |
#writer ⇒ Object
Returns the value of attribute writer.
7 8 9 |
# File 'lib/objective_command/datas/pipe.rb', line 7 def writer @writer end |
Instance Method Details
#close ⇒ Object Also known as: clean
23 24 25 26 |
# File 'lib/objective_command/datas/pipe.rb', line 23 def close @reader.close unless @reader.closed? @writer.close unless @writer.closed? end |
#each_line(&block) ⇒ Object
31 32 33 |
# File 'lib/objective_command/datas/pipe.rb', line 31 def each_line &block open.each_line(&block) end |
#open(mode = :r) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/objective_command/datas/pipe.rb', line 12 def open ( mode=:r ) case mode.to_sym when :r @writer.close @reader when :w @reader.close @writer else raise ArgumentError, "Bad open mode: #{mode.inspect}" end end |
#read ⇒ Object
34 35 36 |
# File 'lib/objective_command/datas/pipe.rb', line 34 def read open.read end |
#to_io_for_ocmd ⇒ Object
28 29 30 |
# File 'lib/objective_command/datas/pipe.rb', line 28 def to_io_for_ocmd open(open_mode) end |