class Cucumber::MultilineArgument::DataTable::DataTablePrinter
def format_cell(cell, col_width)
def format_cell(cell, col_width) cell_text = escape_cell(cell.value.to_s) cell_text_width = cell_text.unpack('U*').length padded_text = cell_text + (' ' * (col_width - cell_text_width)) prefix = prefixes[cell.status] "#{prefix}#{padded_text} " end
def format_row(row)
def format_row(row) row_start = "#{' ' * indentation}| " row_end = '|' cells = row.map.with_index do |cell, i| format_cell(cell, data_table.col_width(i)) end row_start + cells.join('| ') + row_end end
def initialize(data_table, indentation, prefixes)
def initialize(data_table, indentation, prefixes) @data_table = data_table @indentation = indentation @prefixes = prefixes end
def to_s
def to_s leading_row = "\n" end_indentation = indentation - 2 trailing_row = "\n#{' ' * end_indentation}" table_rows = data_table.cell_matrix.map { |row| format_row(row) } leading_row + table_rows.join("\n") + trailing_row end