Class: TeeIO
Overview
TeeIO
Class to allow the storage and forwarding of input at the same time For example if stderr output should be handled by our code but at the same time be put out directly
To prevent for example double error messages data can be filtered before being passed on to the io_object Only the data passed along is filtered, not the data stored in this IO object.
Instance Method Summary collapse
-
#initialize(io_object, io_filter = []) ⇒ TeeIO
constructor
A new instance of TeeIO.
- #write(data) ⇒ Object
Constructor Details
#initialize(io_object, io_filter = []) ⇒ TeeIO
Returns a new instance of TeeIO.
29 30 31 32 33 |
# File 'lib/tee_io.rb', line 29 def initialize(io_object, io_filter = []) super() @io_object = io_object @io_filter = Array(io_filter) end |
Instance Method Details
#write(data) ⇒ Object
35 36 37 38 |
# File 'lib/tee_io.rb', line 35 def write(data) super @io_object.puts(data) unless @io_filter.include?(data) end |