class Sheen::Table

Overview

A table renderer.

Defined in:

sheen/table.cr

Constant Summary

HEADER_ROW = -1

The header row sentinel passed to the #style block for header cells.

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new #

Builds an empty table with defaults:

  • rounded border
  • every border except row separator on
  • wrapping enabled

[View source]

Class Method Detail

def self.data_to_matrix(data : Data) : Array(Array(String)) #

Materializes data into a dense row-based matrix, normalizing row padding to the max column size.


[View source]
def self.default_styles(_row : Int32, _col : Int32) : Style #

The default per-cell style. No attributes for any position.


[View source]

Instance Method Detail

def border(border : Border) : Table #

Sets the border glyph set.

Returns self.


[View source]
def border : Border #

[View source]
def border_bottom(val : Bool) : Table #

Toggles the bottom border on or off.

Returns self.


[View source]
def border_bottom? : Bool #

[View source]
def border_column(val : Bool) : Table #

Toggles the column border separator on or off.

Returns self.


[View source]
def border_column? : Bool #

[View source]
def border_header(val : Bool) : Table #

Toggles the header separator border on or off.

Returns self.


[View source]
def border_header? : Bool #

[View source]
def border_left(val : Bool) : Table #

Toggles the left border on or off.

Returns self.


[View source]
def border_left? : Bool #

[View source]
def border_right(val : Bool) : Table #

Toggles the right border on or off.

Returns self.


[View source]
def border_right? : Bool #

[View source]
def border_row(val : Bool) : Table #

Toggles the row border separator on or off.

Returns self.


[View source]
def border_row? : Bool #

[View source]
def border_style(style : Style) : Table #

Sets the style applied to every border.

Returns self.


[View source]
def border_style : Style #

[View source]
def border_top(val : Bool) : Table #

Toggles the top border on or off.

Returns self.


[View source]
def border_top? : Bool #

[View source]
def cell_style(row : Int32, col : Int32) : Style #

The style for the cell at (row, col). The header row is HEADER_ROW.


[View source]
def clear_rows! : Table #

Clears all the data rows.

Returns self.


[View source]
def data(source : Data) : Table #

Sets the table data source.

Returns self.


[View source]
def data : Data #

[View source]
def headers(names : Enumerable(String)) : Table #

Sets the table headers from each one of names.

Returns self.


[View source]
def headers : Array(String) #

[View source]
def headers(*names : String) : Table #

Sets the table headers from each one of names.

Returns self.


[View source]
def height(h : Int32) : Table #

Sets a manual table height in rows. Clipped rows overflow to an ellipses.

Returns self.


[View source]
def height : Int32 #

[View source]
def offset(o : Int32) : Table #

Sets the starting row offset for rendering.

Returns self.


[View source]
def offset : Int32 #

[View source]
def render : String #

Renders the table to a string. Pads headers out to the column count in place.


[View source]
def row(*cells : String) : Table #

Appends a row build from cells, when the data source is a StringData

Returns self.


[View source]
def rows(rows : Enumerable(Array(String))) : Table #

Appends multiple rows, when the data source is a StringData.

Returns self.


[View source]
def rows(*rows : Array(String)) : Table #

Appends multiple rows, when the data source is a StringData.

Returns self.


[View source]
def style(&block : Int32, Int32 -> Style) : Table #

Sets the per-cell style block invoked with (row, column). The header row is HEADER_ROW.

Returns self.


[View source]
def to_s(io : IO) : Nil #

Renders the table to io.


[View source]
def use_manual_height? : Bool #

[View source]
def width(w : Int32) : Table #

Sets the target table width in columns. The resizer expands or shrinks columns to fit.

Returns self.


[View source]
def width : Int32 #

[View source]
def wrap(w : Bool) : Table #

Sets whether cell content wraps or not.

Returns self.


[View source]
def wrap? : Bool #

[View source]