format::colorize
: Turns any string into a string with colorsformat::table
: Turns arrays into a table formatted string for human consumption
Type: Ruby 4.x API
Useful when dumping text to the console with flying colors. Normally this would only be used for puppet types like plans and other scenarios where text can be displayed directory on the console.
$red_string = colorize('red alert', red)
$red_string = colorize('red alert', 33)
The format::colorize function.
Returns: String
The supplied string surrounded with color codes.
colorize('hi', red)
colorize('red alert', fatal)
Data type: String
The string you wish to colorize.
Data type: Enum[red, green, yellow, warning, fatal, good]
The color you want to color it.
The format::colorize function.
Returns: String
The supplied string surrounded with color codes.
colorize('red alert', red)
colorize('red alert', 33)
Data type: String
The string you wish to colorize.
Data type: Integer
The color you want to color it.
Type: Ruby 4.x API
Useful when dumping text to the console in a nice table format. Normally this would only be used for puppet types like plans and other scenarios where text can be displayed directory on the console.
- Note For a list of style options that can be supplied please see the tablestyle datatype.
$t = format::table([['one', 1], ['two', 2]])
$rows = [['one', 1], ['two', 2]]
$t_style = {width => 80}
$t = format::table({'title' => 'Some title', 'rows' => rows, 'style' => $t_style })
The format::table function.
Returns: String
A formatted table in string form.
$t = format::table([['one', 1], ['two', 2]])
=> "+-----+---+\n| One | 1 |\n| Two | 2 |\n+-----+---+"
Data type: Format::TableRows
That data you wish to transform into a table.
The format::table function.
Returns: String
A formatted table in string form.
$rows = [['one', 1], ['two', 2]]
$t = format::table({'title' => 'Some title', 'rows' => rows, 'style' => {width => 80}})
=> "+-----+---+\n| title |\n+-----+---+\n| One | 1 |\n| Two | 2 |\n+-----+---+"
Data type: Format::TerminalTable
That data and other settings you wish to produce a table with.
The Format::TableRows data type.
Alias of Variant[Array[0,0], Array[Array]]
The Format::TableStyle data type.
Alias of
Struct[{
width => Optional[Integer],
border_top => Optional[Boolean],
border_bottom => Optional[Boolean],
all_separators => Optional[Boolean],
padding_left => Optional[Integer],
padding_right => Optional[Integer],
border_x => Optional[String],
border_i => Optional[String],
border => Optional[String]
}]
The Format::TerminalTable data type.
Alias of
Struct[{
title => Optional[String],
head => Optional[Array[String]],
rows => Format::TableRows,
style => Optional[Format::TableStyle]
}]