class Athena::Console::Helper::Table::Style
inherits Reference
#
Represents the overall style for a table. Including the characters that make up the row/column separators, crosses, cell formats, and default alignment.
This class provides a fluent interface for configuring each part of the style.
Methods#
#align(align : ACON::Helper::Table::Alignment) : self
#
Sets the default cell alignment for the table.
#border_format(format : String) : self
#
Sets the sprintf
format string for the border, defaulting to "%s"
.
For example, if set to "~%s~"
with the cell's content being text
:
~+------+~
~|~ text ~|~
~+------+~
Warning
Customizing this format can mess with the formatting of the whole table.
#cell_header_format(format : String) : self
#
Sets the sprintf
format string used for table headings, defaulting to "<info>%s</info>"
.
#cell_row_content_format(format : String) : self
#
Sets the sprintf
format string used for cell contents, defaulting to " %s "
.
For example, if set to " =%s= "
with the cell's content being text
:
+--------+
| =text= |
+--------+
#cell_row_format(format : String) : self
#
Sets the sprintf
format string used for cell contents, defaulting to "%s"
.
For example, if set to "~%s~"
with the cell's content being text
:
+------+
|~ text ~|
+------+
Warning
Customizing this format can mess with the formatting of the whole table.
#clone
#
Returns a copy of self
with all instance variables cloned.
#crossing_chars(cross : String | Char, top_left : String | Char, top_middle : String | Char, top_right : String | Char, middle_right : String | Char, bottom_right : String | Char, bottom_middle : String | Char, bottom_left : String | Char, middle_left : String | Char, top_left_bottom : String | Char | Nil = nil, top_middle_bottom : String | Char | Nil = nil, top_right_bottom : String | Char | Nil = nil) : self
#
Sets the crossing characters individually, defaulting to "+"
.
See #default_crossing_char(char)
to default them all to a single character.
1═══════════════2══════════════════════════2══════════════════3
║ ISBN │ Title │ Author ║
8═══════════════0══════════════════════════0══════════════════4
║ 99921-58-10-7 │ Divine Comedy │ Dante Alighieri ║
║ 9971-5-0210-0 │ A Tale of Two Cities │ Charles Dickens ║
8───────────────0──────────────────────────0──────────────────4
║ 960-425-059-0 │ The Lord of the Rings │ J. R. R. Tolkien ║
║ 80-902734-1-6 │ And Then There Were None │ Agatha Christie ║
7═══════════════6══════════════════════════6══════════════════5
Legend:
- #0 cross
- #1 top_left
- #2 top_middle
- #3 top_right
- #4 middle_right
- #5 bottom_right
- #6 bottom_middle
- #7 bottom_left
-
#8 middle_left
-
#8 top_left_bottom - defaults to middle_left if
nil
- #0 top_middle_bottom - defaults to cross if
nil
- #4 top_right_bottom - defaults to middle_right if
nil
#default_crossing_char(char : String | Char) : self
#
Sets the default character used for each cross type.
See #crossing_chars
.
#footer_title_format(format : String) : self
#
Sets the sprintf
format string used for footer titles, defaulting to "<fg=black;bg=white;options=bold> %s </>"
.
#header_title_format(format : String) : self
#
Sets the sprintf
format string used for header titles, defaulting to "<fg=black;bg=white;options=bold> %s </>"
.
#horizontal_border_chars(outside : String | Char, inside : String | Char | Nil = nil) : self
#
Sets the horizontal border chars, defaulting to "-"
.
inside defaults to outside if not provided.
For example:
╔═══════════════╤══════════════════════════╤══════════════════╗
1 ISBN 2 Title │ Author ║
╠═══════════════╪══════════════════════════╪══════════════════╣
║ 99921-58-10-7 │ Divine Comedy │ Dante Alighieri ║
║ 9971-5-0210-0 │ A Tale of Two Cities │ Charles Dickens ║
║ 960-425-059-0 │ The Lord of the Rings │ J. R. R. Tolkien ║
║ 80-902734-1-6 │ And Then There Were None │ Agatha Christie ║
╚═══════════════╧══════════════════════════╧══════════════════╝
Legend:
- #1 outside
- #2 inside
#padding_char(char : Char) : self
#
Sets the the character that is added to the cell to ensure its content has the correct ACON::Helper::Table::Alignment
, defaulting to ' '
.
For example, if the padding character was '_'
with a left alignment:
+-----+
| 7 __|
+-----+
#vertical_border_chars(outside : String | Char, inside : String | Char | Nil = nil) : self
#
Sets the vertical border chars, defaulting to "|"
.
inside defaults to outside if not provided.
For example:
╔═══════════════╤══════════════════════════╤══════════════════╗
║ ISBN │ Title │ Author ║
╠═══════1═══════╪══════════════════════════╪══════════════════╣
║ 99921-58-10-7 │ Divine Comedy │ Dante Alighieri ║
║ 9971-5-0210-0 │ A Tale of Two Cities │ Charles Dickens ║
╟───────2───────┼──────────────────────────┼──────────────────╢
║ 960-425-059-0 │ The Lord of the Rings │ J. R. R. Tolkien ║
║ 80-902734-1-6 │ And Then There Were None │ Agatha Christie ║
╚═══════════════╧══════════════════════════╧══════════════════╝
Legend:
- #1 outside
- #2 inside