Athena::Console::Helper::Formatter
Inherits Athena::Console::Helper / Athena::Console::Helper::Interface / Reference / Object
Provides additional ways to format output messages than ACON::Formatter::OutputStyle can do alone, such as:
- Printing messages in a section
- Printing messages in a block
- Print truncated messages.
The provided methods return a String which could then be passed to ACON::Output::Interface#print or ACON::Output::Interface#puts.
Instance methods
Prints the provided messages in a block formatted according to the provided style, with a total width a bit more than the longest line.
The large options adds additional padding, one blank line above and below the messages, and 2 more spaces on the left and right.
output.puts formatter.format_block({"Error!", "Something went wrong"}, "error", true)
Prints the provided message in the provided section. Optionally allows setting the style of the section.
[SomeSection] Here is some message related to that section
output.puts formatter.format_section "SomeSection", "Here is some message related to that section"
Truncates the provided message to be at most length characters long, with the optional suffix appended to the end.
message = "This is a very long message, which should be truncated"
truncated_message = formatter.truncate message, 7
output.puts truncated_message # => This is...
If length is negative, it will start truncating from the end.
message = "This is a very long message, which should be truncated"
truncated_message = formatter.truncate message, -4
output.puts truncated_message # => This is a very long message, which should be trunc...