Class: Cuprum::Cli::Dependencies::StandardIo::Mock
- Parent Namespace
- Cuprum::Cli::Dependencies::StandardIo
- Inherited Classes
- Cuprum::Cli::Dependencies::StandardIo
>
Object
- Defined In
- lib/cuprum/cli/dependencies/standard_io/mock.rb
Table Of Contents
Overview
Mock implementation of StandardIo for testing purposes.
Back To Top
Class Methods
.append_for_read(*messages, io:) => IO
Utility method for appending readable data to a StringIO stream.
Parameters
- messages (Array<String>) — the messages to append. Will be appended
to the stream in the provided order.
- io (IO) — the io stream to append.
Returns
Back To Top
Constructor
#initialize(error_stream: StringIO.new, input_stream: StringIO.new, output_stream: StringIO.new) => Mock
Parameters
- error_stream (IO) — the error stream. Defaults to an instance of
StringIO.
- input_stream (IO) — the input stream. Defaults to an instance of
StringIO.
- output_stream (IO) — the output stream. Defaulst to an instance of
StringIO.
Returns
- (Mock) — a new instance of Mock
Back To Top
Instance Attributes
#combined_stream => IO (readonly)
Returns
- (IO) — a combined input/output stream representing all IO activity.
Back To Top
Instance Methods
#color(text, color) => String
- Inherited From
- Cuprum::Cli::Dependencies::StandardIo
Wraps the text in an ANSI color escape code.
Parameters
- text (String) — the text to colorize.
- color (String) — the color to apply.
Returns
- (String) — the colorized string.
Raises
- (KeyError) — if the requested color does not have an escape code.
#error_stream => IO
Returns
#output_stream => IO
Returns
- (IO) — the output stream.
Requests a newline-terminated string from the input stream.
- (String) — the returned input string.
#write_error(message = nil, newline: true) => nil
Writes the given message to the error stream.
If no error message is given, prints a newline only.
Parameters
- message (String, nil) — the message to write.
- newline (true, false) — if true, appends a newline to the message if
it does not have a newline. Defaults to true.
Returns
#write_output(message = nil, newline: true) => nil
Writes the given message to the output stream.
If no message is given, prints a newline only.
Parameters
- message (String, nil) — the message to write.
- newline (true, false) — if true, appends a newline to the message if
it does not have a newline. Defaults to true.
Returns
Back To Top
Back to
Documentation |
Reference
|
Cuprum
|
Cuprum::Cli
|
Cuprum::Cli::Dependencies
|
Cuprum::Cli::Dependencies::StandardIo