IO.ANSI.Table.Header (IO ANSI Table v1.0.14) View Source

Finds the alignment or sort attribute of a header. Also converts a header into a "heading".

Link to this section Summary

Functions

Finds the alignment or sort attribute of a header.

Link to this section Types

Specs

align_attr() :: :left | :center | :right

Specs

align_spec() :: t() | {align_attr(), t()}

Specs

sort_attr() :: MapSorter.SortSpec.sort_dir()

Specs

sort_spec() :: MapSorter.SortSpec.t()

Specs

sort_symbol() :: {sort_attr(), String.t()} | {:pos, sym_pos() | [sym_pos()]}

Specs

sym_pos() :: :leading | :trailing

Specs

t() :: Map.key()

Link to this section Functions

Link to this function

find_attr(header, specs, default_attr)

View Source

Specs

find_attr(t(), [align_spec() | sort_spec()], :left | :asc) ::
  align_attr() | sort_attr() | nil

Finds the alignment or sort attribute of a header.

Examples

iex> alias IO.ANSI.Table.Header
iex> sort_specs = ["dept", desc: "hired"]
iex> {
...>   Header.find_attr("dept" , sort_specs, :asc),
...>   Header.find_attr("hired", sort_specs, :asc),
...>   Header.find_attr("job"  , sort_specs, :asc)
...> }
{:asc, :desc, nil}

iex> alias IO.ANSI.Table.Header
iex> sort_specs = ["dept", desc: {"hired", Date}]
iex> {
...>   Header.find_attr("dept" , sort_specs, :asc),
...>   Header.find_attr("hired", sort_specs, :asc),
...>   Header.find_attr("job"  , sort_specs, :asc)
...> }
{:asc, :desc, nil}

iex> alias IO.ANSI.Table.Header
iex> sort_specs = [{"hired", Date}, "job", {:desc, "dept"}]
iex> {
...>   Header.find_attr("dept" , sort_specs, :asc),
...>   Header.find_attr("hired", sort_specs, :asc),
...>   Header.find_attr("job"  , sort_specs, :asc)
...> }
{:desc, :asc, :asc}

iex> alias IO.ANSI.Table.Header
iex> sort_specs = [{"hired", Date}, desc: "dept"]
iex> {
...>   Header.find_attr("dept" , sort_specs, :asc),
...>   Header.find_attr("hired", sort_specs, :asc),
...>   Header.find_attr("job"  , sort_specs, :asc)
...> }
{:desc, :asc, nil}

iex> alias IO.ANSI.Table.Header
iex> align_specs = ["dept", right: "hired"]
iex> {
...>   Header.find_attr("dept" , align_specs, :left),
...>   Header.find_attr("hired", align_specs, :left),
...>   Header.find_attr("job"  , align_specs, :left)
...> }
{:left, :right, nil}
Link to this function

to_heading(header, spec)

View Source

Specs

to_heading(t(), IO.ANSI.Table.Spec.t()) :: String.t()