Class: Kosi::Table
- Inherits:
-
Object
- Object
- Kosi::Table
- Defined in:
- lib/table.rb
Overview
Table
Instance Attribute Summary collapse
-
#align ⇒ Object
readonly
Returns the value of attribute align.
-
#connector_char ⇒ Object
readonly
Returns the value of attribute connector_char.
-
#header ⇒ Object
readonly
Returns the value of attribute header.
-
#horizontal_border_char ⇒ Object
readonly
Returns the value of attribute horizontal_border_char.
-
#separate_each_row ⇒ Object
readonly
Returns the value of attribute separate_each_row.
-
#vertical_border_char ⇒ Object
readonly
Returns the value of attribute vertical_border_char.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Table
constructor
A new instance of Table.
- #render(rows) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Table
Returns a new instance of Table.
13 14 15 16 17 18 19 20 |
# File 'lib/table.rb', line 13 def initialize( = {}) @align = Kosi::Align.new() @header = Kosi::Header.new() @connector_char = Kosi::ConnectorChar.new() @horizontal_border_char = Kosi::HorizontalBorderChar.new() @vertical_border_char = Kosi::VerticalBorderChar.new() @separate_each_row = Kosi::SeparateEachRow.new() end |
Instance Attribute Details
#align ⇒ Object (readonly)
Returns the value of attribute align.
10 11 12 |
# File 'lib/table.rb', line 10 def align @align end |
#connector_char ⇒ Object (readonly)
Returns the value of attribute connector_char.
10 11 12 |
# File 'lib/table.rb', line 10 def connector_char @connector_char end |
#header ⇒ Object (readonly)
Returns the value of attribute header.
10 11 12 |
# File 'lib/table.rb', line 10 def header @header end |
#horizontal_border_char ⇒ Object (readonly)
Returns the value of attribute horizontal_border_char.
10 11 12 |
# File 'lib/table.rb', line 10 def horizontal_border_char @horizontal_border_char end |
#separate_each_row ⇒ Object (readonly)
Returns the value of attribute separate_each_row.
10 11 12 |
# File 'lib/table.rb', line 10 def separate_each_row @separate_each_row end |
#vertical_border_char ⇒ Object (readonly)
Returns the value of attribute vertical_border_char.
10 11 12 |
# File 'lib/table.rb', line 10 def vertical_border_char @vertical_border_char end |
Instance Method Details
#render(rows) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/table.rb', line 22 def render(rows) check_rows_type(rows) check_each_array_length(rows) header = read_header escaped_rows = escape_ansi_escape_sequence(rows) max_lengths = get_max_lengths(escaped_rows, header) table_format_rows = get_table_format_rows(rows, max_lengths, header) table_format_rows.join("\n") + "\n" end |