class
Sheen::Table
- Sheen::Table
- Reference
- Object
Overview
A table renderer.
Defined in:
sheen/table.crConstant Summary
-
HEADER_ROW =
-1 -
The header row sentinel passed to the
#styleblock for header cells.
Constructors
-
.new
Builds an empty table with defaults: - rounded border - every border except row separator on - wrapping enabled
Class Method Summary
-
.data_to_matrix(data : Data) : Array(Array(String))
Materializes data into a dense row-based matrix, normalizing row padding to the max column size.
-
.default_styles(_row : Int32, _col : Int32) : Style
The default per-cell style.
Instance Method Summary
-
#border(border : Border) : Table
Sets the border glyph set.
- #border : Border
-
#border_bottom(val : Bool) : Table
Toggles the bottom border on or off.
- #border_bottom? : Bool
-
#border_column(val : Bool) : Table
Toggles the column border separator on or off.
- #border_column? : Bool
-
#border_header(val : Bool) : Table
Toggles the header separator border on or off.
- #border_header? : Bool
-
#border_left(val : Bool) : Table
Toggles the left border on or off.
- #border_left? : Bool
-
#border_right(val : Bool) : Table
Toggles the right border on or off.
- #border_right? : Bool
-
#border_row(val : Bool) : Table
Toggles the row border separator on or off.
- #border_row? : Bool
-
#border_style(style : Style) : Table
Sets the style applied to every border.
- #border_style : Style
-
#border_top(val : Bool) : Table
Toggles the top border on or off.
- #border_top? : Bool
-
#cell_style(row : Int32, col : Int32) : Style
The style for the cell at (row, col).
-
#clear_rows! : Table
Clears all the data rows.
-
#data(source : Data) : Table
Sets the table data source.
- #data : Data
-
#headers(names : Enumerable(String)) : Table
Sets the table headers from each one of names.
- #headers : Array(String)
-
#headers(*names : String) : Table
Sets the table headers from each one of names.
-
#height(h : Int32) : Table
Sets a manual table height in rows.
- #height : Int32
-
#offset(o : Int32) : Table
Sets the starting row offset for rendering.
- #offset : Int32
-
#render : String
Renders the table to a string.
-
#row(*cells : String) : Table
Appends a row build from cells, when the data source is a
StringData -
#rows(rows : Enumerable(Array(String))) : Table
Appends multiple rows, when the data source is a
StringData. -
#rows(*rows : Array(String)) : Table
Appends multiple rows, when the data source is a
StringData. -
#style(&block : Int32, Int32 -> Style) : Table
Sets the per-cell style block invoked with (row, column).
-
#to_s(io : IO) : Nil
Renders the table to io.
- #use_manual_height? : Bool
-
#width(w : Int32) : Table
Sets the target table width in columns.
- #width : Int32
-
#wrap(w : Bool) : Table
Sets whether cell content wraps or not.
- #wrap? : Bool
Constructor Detail
Builds an empty table with defaults:
- rounded border
- every border except row separator on
- wrapping enabled
Class Method Detail
Materializes data into a dense row-based matrix, normalizing row padding to the max column size.
The default per-cell style. No attributes for any position.
Instance Method Detail
Toggles the bottom border on or off.
Returns self.
Toggles the column border separator on or off.
Returns self.
Toggles the header separator border on or off.
Returns self.
Toggles the left border on or off.
Returns self.
Toggles the right border on or off.
Returns self.
Toggles the row border separator on or off.
Returns self.
Sets the style applied to every border.
Returns self.
The style for the cell at (row, col). The header row is HEADER_ROW.
Sets the table headers from each one of names.
Returns self.
Sets the table headers from each one of names.
Returns self.
Sets a manual table height in rows. Clipped rows overflow to an ellipses.
Returns self.
Sets the starting row offset for rendering.
Returns self.
Appends a row build from cells, when the data source is a StringData
Returns self.
Appends multiple rows, when the data source is a StringData.
Returns self.
Appends multiple rows, when the data source is a StringData.
Returns self.
Sets the per-cell style block invoked with (row, column). The header row is HEADER_ROW.
Returns self.
Sets the target table width in columns. The resizer expands or shrinks columns to fit.
Returns self.