module Cucumber::Core::Gherkin::Writer::HasRows
def column_length(column)
def column_length(column) lengths = rows.transpose.map { |r| r.map(&:length).max } lengths[column] end
def justify_cell(cell, position)
def justify_cell(cell, position) cell.ljust(column_length(position)) end
def pad(row)
def pad(row) row.map.with_index { |text, position| justify_cell(text, position) } end
def row(*cells)
def row(*cells) rows << cells end
def row_statements(indent = nil)
def row_statements(indent = nil) rows.map { |row| indent(table_row(row), indent) } end
def rows
def rows @rows ||= [] end
def table_row(row)
def table_row(row) padded = pad(row) "| #{padded.join(' | ')} |" end