class TablePal::PlainText

Attributes

coloured[R]
output[R]
result[R]
table[R]

Public Class Methods

new(table:, coloured: false, output: true) click to toggle source
# File lib/plain_text.rb, line 6
def initialize(table:, coloured: false, output: true)
  @table    = table
  @coloured = coloured
  @output   = output
  @result   = ''

  table.rows.each do |row|
    print_row(row)
  end
end

Public Instance Methods

to_s() click to toggle source
# File lib/plain_text.rb, line 17
def to_s
  result
end

Private Instance Methods

add_chars(chars) click to toggle source
# File lib/plain_text.rb, line 99
def add_chars(chars)
  @result.concat(chars)

  print chars if output
end
add_new_line() click to toggle source
# File lib/plain_text.rb, line 105
def add_new_line
  @result.concat("\n")

  puts if output
end
empty() click to toggle source
# File lib/plain_text.rb, line 86
def empty
  table.columns.map do |column|
    char = ' '
    add_chars column.left_border
    add_chars column.left_padding_char(char)
    add_chars char * column.width
    add_chars column.right_padding_char(char)
    add_chars column.right_border
  end

  add_new_line
end
print_cell(cell) click to toggle source
print_cells(row) click to toggle source
print_heading_row(row) click to toggle source
print_regular_row(row) click to toggle source
print_row(row) click to toggle source
print_section_end_row(row) click to toggle source
print_subheading_row(row) click to toggle source
underline() click to toggle source
# File lib/plain_text.rb, line 73
def underline
  table.columns.map do |column|
    char = '-'
    add_chars column.left_border
    add_chars column.left_padding_char(char)
    add_chars char * column.width
    add_chars column.right_padding_char(char)
    add_chars column.right_border
  end

  add_new_line
end