IO ANSI Table v0.1.0 IO.ANSI.Table.Style

Defines functions to retrieve properties of predefined table styles.

Summary

Functions

Retrieves the border attribute of a given table style

Retrieves the border widths of a given table style and line type

Retrieves the borders of a given table style and line type

Retrieves the dash of a given table style and line type

Retrieves the filler attribute of a given table style

Retrieves the table style for a given table style tag

Retrieves the key attribute of a given table style and line type

Retrieves the non key attribute of a given table style and line type

Retrieves a list of interpolated texts (one per table style) or optionally passes each interpolated text to a function

Functions

border_attr(style)
border_attr(atom) :: [atom] | atom | nil

Retrieves the border attribute of a given table style.

Examples

iex> alias IO.ANSI.Table.Style
iex> Style.border_attr(:green)
[:light_yellow, :light_green_background]
border_widths(style, type)
border_widths(atom, atom) :: {[...], [...], [...]} | nil

Retrieves the border widths of a given table style and line type.

Examples

iex> alias IO.ANSI.Table.Style
iex> Style.border_widths(:plain, :bottom)
{[2, 0], [0, 3, 0], [0, 2]}

iex> alias IO.ANSI.Table.Style
iex> Style.border_widths(:plain, :header)
{[1, 1], [1, 1, 1], [1, 1]}
borders(style, type)
borders(atom, atom) :: {String.t, String.t, String.t} | nil

Retrieves the borders of a given table style and line type.

Examples

iex> alias IO.ANSI.Table.Style
iex> Style.borders(:cyan, :bottom)
{"╚═", "═╩═", "═╝"}
dash(style, type)
dash(atom, atom) :: String.t | nil

Retrieves the dash of a given table style and line type.

Examples

iex> IO.ANSI.Table.Style
iex> Style.dash(:dark, :top)
"═"
filler_attr(style)
filler_attr(atom) :: [atom] | atom | nil

Retrieves the filler attribute of a given table style.

Examples

iex> alias IO.ANSI.Table.Style
iex> Style.filler_attr(:mixed)
:light_green_background
for(tag)
for(String.t) :: {:ok, atom} | :error

Retrieves the table style for a given table style tag.

Examples

iex> alias IO.ANSI.Table.Style
iex> Style.for("light")
{:ok, :light}
key_attr(style, type)
key_attr(atom, atom) :: [atom] | atom | nil

Retrieves the key attribute of a given table style and line type.

Examples

iex> alias IO.ANSI.Table.Style
iex> Style.key_attr(:light, :data)
:light_cyan
non_key_attr(style, type)
non_key_attr(atom, atom) :: [atom] | atom | nil

Retrieves the non key attribute of a given table style and line type.

Examples

iex> alias IO.ANSI.Table.Style
iex> Style.non_key_attr(:cyan, :data)
[:black, :light_cyan_background]
texts(template, fun \\ &(&1))
texts(String.t, (String.t -> any)) :: [any]

Retrieves a list of interpolated texts (one per table style) or optionally passes each interpolated text to a function.

Examples

alias IO.ANSI.Table.Style
Style.texts "  - `&style`&filler - &note\n"

alias IO.ANSI.Table.Style
Style.texts "  - `&style`&filler - &note", &IO.puts/1

Interpolation placeholders

  • &style - table style (e.g. :light)
  • &tag - table style tag (e.g. light)
  • &filler - padding after &style or &tag
  • &note - table style note
  • &rank - table style rank