Class: Cuprum::Cli::Dependencies::StandardIo
- Parent Namespace
- Cuprum::Cli::Dependencies
- Defined In
- lib/cuprum/cli/dependencies/standard_io.rb
Table Of Contents
Overview
Utility wrapping standard input, output, and error IO streams.
Back To Top
Direct Subclasses
Cuprum::Cli::Dependencies::StandardIo::Mock
Back To Top
Defined Under Namespace
- Classes
- Mock
- Modules
- Helpers
Back To Top
Constructor
#initialize(error_stream: -> { $stderr }, input_stream: -> { $stdin }, output_stream: -> { $stdout }) => StandardIo
Parameters
- error_stream (IO) — the error stream. Defaults to $stderr.
- input_stream (IO) — the input stream. Defaults to $stdin.
- output_stream (IO) — the output stream. Defaulst to $stdout.
Returns
- (StandardIo) — a new instance of StandardIo
Back To Top
Instance Methods
#color(text, color) => String
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.
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