class Cucumber::MultilineArgument::DataTable::DataTablePrinter
Attributes
Public Class Methods
Source
# File lib/cucumber/multiline_argument/data_table.rb, line 398 def initialize(data_table, indentation, prefixes) @data_table = data_table @indentation = indentation @prefixes = prefixes end
Public Instance Methods
Source
# File lib/cucumber/multiline_argument/data_table.rb, line 404 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
Private Instance Methods
Source
# File lib/cucumber/multiline_argument/data_table.rb, line 423 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
Source
# File lib/cucumber/multiline_argument/data_table.rb, line 414 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