Class: Croaky::IO::IoStream
- Inherits:
-
Object
- Object
- Croaky::IO::IoStream
- Includes:
- IoCapturable
- Defined in:
- lib/croaky/io/io_stream.rb
Overview
IO adapter
Instance Attribute Summary collapse
-
#stderr_stream ⇒ Object
readonly
Returns the value of attribute stderr_stream.
-
#stdout_stream ⇒ Object
readonly
Returns the value of attribute stdout_stream.
Instance Method Summary collapse
- #capture_io ⇒ Object
-
#initialize(stdout_stream, stderr_stream) ⇒ IoStream
constructor
A new instance of IoStream.
- #read_captured_io ⇒ Object
- #restore_io ⇒ Object
Constructor Details
#initialize(stdout_stream, stderr_stream) ⇒ IoStream
Returns a new instance of IoStream.
13 14 15 16 |
# File 'lib/croaky/io/io_stream.rb', line 13 def initialize(stdout_stream, stderr_stream) @stdout_stream = stdout_stream @stderr_stream = stderr_stream end |
Instance Attribute Details
#stderr_stream ⇒ Object (readonly)
Returns the value of attribute stderr_stream.
11 12 13 |
# File 'lib/croaky/io/io_stream.rb', line 11 def stderr_stream @stderr_stream end |
#stdout_stream ⇒ Object (readonly)
Returns the value of attribute stdout_stream.
11 12 13 |
# File 'lib/croaky/io/io_stream.rb', line 11 def stdout_stream @stdout_stream end |
Instance Method Details
#capture_io ⇒ Object
18 19 20 21 |
# File 'lib/croaky/io/io_stream.rb', line 18 def capture_io stdout_stream.capture_io stderr_stream.capture_io end |
#read_captured_io ⇒ Object
28 29 30 31 |
# File 'lib/croaky/io/io_stream.rb', line 28 def read_captured_io captured = [stdout_stream.read_captured_io, stderr_stream.read_captured_io] captured.flatten.reject { |s| s.to_s.empty? }.join($INPUT_RECORD_SEPARATOR) end |
#restore_io ⇒ Object
23 24 25 26 |
# File 'lib/croaky/io/io_stream.rb', line 23 def restore_io stdout_stream.restore_io stderr_stream.restore_io end |