class

Crab::Table

Inherits Crab::Renderable / Reference / Object

A class to create a table with a title It can be used to create a table with data inside

Constructors

new(column_names : Array(String), title : String = "", crab_codes : String = "", box_crab_codes : String = "", header_crab_codes : String = "", style : String = "default")

Create a new table: The arguments are:

  • column_names: An array of strings with the names of the columns (mandatory)
  • title: A string with the title of the table (optional)
  • crab_codes: A string with the crab codes to be used in the table (optional)
  • box_crab_codes: A string with the crab codes to be used in the box (optional)
  • header_crab_codes: A string with the crab codes to be used in the header/column names (optional)
  • style: A string with the style of the table (optional) The styles are:
  • default: The default style
  • double: The double style
  • ascii: The ascii style if otherwise specified, the default style will be used
Source

Instance methods

add_row(row : Array(String))

A method to add a row of data to the table It takes an array of strings and adds it to the table

Source
box_crab_codes
Source
box_crab_codes=(box_crab_codes : String)
Source
columns
Source
crab_codes
Source
crab_codes=(crab_codes : String)
Source
header_crab_codes
Source
header_crab_codes=(header_crab_codes : String)
Source
padd_row(row)

A method to easily prepare a row of data to be added to the table It takes an array of strings, ints, floats, bools or nil and adds it to the table by calling prepare_row and add_row

Source
prepare_row(row : Array(T)) forall T

A method to prepare a row of data to be only strings It takes an array of strings, ints, floats, bools or nil and returns an array of strings with the data prepared With crab codes For more information see Crab::TypeParser

Source
render

The render method of the table It takes no arguments and returns a string with the table rendered Will be directly called by an Crab::Ansi_Parser or Crab.puts method If possible do not call directly

Source
row_parser(row : Array(String), codes : String, vertical_char : String, width : Int64) : String

A method to somewhat parse the row of data to be printed It takes an array of strings, the crab codes to be used, the vertical character to be used and the width of the table If possible do not call directly

Source
rows
Source
style
Source
style=(style : String)
Source
title
Source
title=(title : String)
Source