Skip to content

Latest commit

 

History

History
207 lines (128 loc) · 4.2 KB

REFERENCE.md

File metadata and controls

207 lines (128 loc) · 4.2 KB

Reference

Table of Contents

Functions

Data types

Functions

format::colorize

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.

Examples

Calling the function
$red_string = colorize('red alert', red)
With a color code
$red_string = colorize('red alert', 33)

format::colorize(String $data, Enum[red, green, yellow, warning, fatal, good] $color_code)

The format::colorize function.

Returns: String The supplied string surrounded with color codes.

Examples
Calling the function
colorize('hi', red)
colorize('red alert', fatal)
data

Data type: String

The string you wish to colorize.

color_code

Data type: Enum[red, green, yellow, warning, fatal, good]

The color you want to color it.

format::colorize(String $data, Integer $color_code)

The format::colorize function.

Returns: String The supplied string surrounded with color codes.

Examples
Calling the function
colorize('red alert', red)
colorize('red alert', 33)
data

Data type: String

The string you wish to colorize.

color_code

Data type: Integer

The color you want to color it.

format::table

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.

Examples

Calling the function
$t = format::table([['one', 1], ['two', 2]])
Calling the function with more parameters
$rows = [['one', 1], ['two', 2]]
$t_style = {width => 80}
$t = format::table({'title' => 'Some title', 'rows' => rows, 'style' => $t_style })

format::table(Format::TableRows $rows)

The format::table function.

Returns: String A formatted table in string form.

Examples
Calling the function
$t = format::table([['one', 1], ['two', 2]])
=> "+-----+---+\n| One | 1 |\n| Two | 2 |\n+-----+---+"
rows

Data type: Format::TableRows

That data you wish to transform into a table.

format::table(Format::TerminalTable $data)

The format::table function.

Returns: String A formatted table in string form.

Examples
Calling the function
$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

Data type: Format::TerminalTable

That data and other settings you wish to produce a table with.

Data types

Format::TableRows

The Format::TableRows data type.

Alias of Variant[Array[0,0], Array[Array]]

Format::TableStyle

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]
  }]

Format::TerminalTable

The Format::TerminalTable data type.

Alias of

Struct[{
  title => Optional[String],
  head => Optional[Array[String]],
  rows => Format::TableRows,
  style => Optional[Format::TableStyle]
  }]