Class: TinyTable::TextFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/tinytable/text_formatter.rb

Constant Summary collapse

CORNER =
'+'
VERTICAL =
'|'
HORIZONTAL =
'-'
PADDING =
' '
STRING_ALIGN =
{
  LEFT => :ljust,
  CENTER => :center,
  RIGHT => :rjust
}

Instance Method Summary collapse

Constructor Details

#initialize(table) ⇒ TextFormatter

Returns a new instance of TextFormatter.



16
17
18
19
# File 'lib/tinytable/text_formatter.rb', line 16

def initialize(table)
  @table = table
  @output = ''
end

Instance Method Details

#renderObject



21
22
23
24
25
26
27
28
29
30
# File 'lib/tinytable/text_formatter.rb', line 21

def render
  clear_output
  precompute_table_layout

  render_header
  render_rows
  render_footer

  @output
end