table_rex v0.10.0 TableRex.Table
A set of functions for working with tables.
The Table
is represented internally as a struct though the
fields are private and must not be accessed directly. Instead,
use the functions in this module.
Summary
Functions
Adds a single row to the table
Adds multiple rows to the table
Removes column meta for all columns, effectively resetting column meta back to the default options across the board
Removes all row data from the table, keeping everything else
Retreives the value of a column meta option at the specified col_index. If no value has been set, default values are returned
Returns a boolean detailing if the passed table has a header row set
Returns a boolean detailing if the passed table has any row data set
Creates a new blank table
Creates a new table with an initial set of rows and an optional header and title
Sets cell level information such as alignment
Sets column level information such as padding and alignment
Sets a list as the optional header row.
Set to nil
or []
to remove an already set header from renders
Sets cell level information for the header cells
Sets a string as the optional table title.
Set to nil
or ""
to remove an already set title from renders
Renders the current table state to string, ready for display via IO.puts/2
or other means
Renders the current table state to string, ready for display via IO.puts/2
or other means
Types
t :: %TableRex.Table{columns: term, default_column: term, header_row: term, rows: term, title: term}
Functions
Specs
add_row(TableRex.Table.t, list) :: TableRex.Table.t
Adds a single row to the table.
Specs
add_rows(TableRex.Table.t, list) :: TableRex.Table.t
Adds multiple rows to the table.
Specs
clear_all_column_meta(TableRex.Table.t) :: TableRex.Table.t
Removes column meta for all columns, effectively resetting column meta back to the default options across the board.
Specs
clear_rows(TableRex.Table.t) :: TableRex.Table.t
Removes all row data from the table, keeping everything else.
Specs
get_column_meta(TableRex.Table.t, integer, atom) :: any
Retreives the value of a column meta option at the specified col_index. If no value has been set, default values are returned.
Specs
has_header?(TableRex.Table.t) :: boolean
Returns a boolean detailing if the passed table has a header row set.
Specs
has_rows?(TableRex.Table.t) :: boolean
Returns a boolean detailing if the passed table has any row data set.
Specs
new :: TableRex.Table.t
Creates a new blank table.
The table created will not be able to be rendered until it has some row data.
Examples
iex> Table.new
%TableRex.Table{}
Specs
new(list, list, String.t) :: TableRex.Table.t
Creates a new table with an initial set of rows and an optional header and title.
Specs
put_cell_meta(TableRex.Table.t, integer, integer, Keyword.t) :: TableRex.Table.t
Sets cell level information such as alignment.
Specs
put_column_meta(TableRex.Table.t, integer | atom | Enum.t, Keyword.t) :: TableRex.Table.t
Sets column level information such as padding and alignment.
Specs
put_header(TableRex.Table.t, list | nil) :: TableRex.Table.t
Sets a list as the optional header row.
Set to nil
or []
to remove an already set header from renders.
Specs
put_header_meta(TableRex.Table.t, integer | Enum.t, Keyword.t) :: TableRex.Table.t
Sets cell level information for the header cells.
Specs
put_title(TableRex.Table.t, String.t | nil) :: TableRex.Table.t
Sets a string as the optional table title.
Set to nil
or ""
to remove an already set title from renders.
Specs
render(TableRex.Table.t, list) :: TableRex.Renderer.render_return
Renders the current table state to string, ready for display via IO.puts/2
or other means.
At least one row must have been added before rendering.
Returns {:ok, rendered_string}
on success and {:error, reason}
on failure.
Specs
render!(TableRex.Table.t, list) ::
String.t |
no_return
Renders the current table state to string, ready for display via IO.puts/2
or other means.
At least one row must have been added before rendering.
Returns the rendered string on success, or raises TableRex.Error
on failure.