module Cucumber::Core::Gherkin::Writer::HasRows

Public Instance Methods

row(*cells) click to toggle source
# File lib/cucumber/core/gherkin/writer/helpers.rb, line 138
def row(*cells)
  rows << cells
end
rows() click to toggle source
# File lib/cucumber/core/gherkin/writer/helpers.rb, line 142
def rows
  @rows ||= []
end

Private Instance Methods

column_length(column) click to toggle source
# File lib/cucumber/core/gherkin/writer/helpers.rb, line 161
def column_length(column)
  lengths = rows.transpose.map { |r| r.map(&:length).max }
  lengths[column]
end
justify_cell(cell, position) click to toggle source
# File lib/cucumber/core/gherkin/writer/helpers.rb, line 166
def justify_cell(cell, position)
  cell.ljust(column_length(position))
end
pad(row) click to toggle source
# File lib/cucumber/core/gherkin/writer/helpers.rb, line 157
def pad(row)
  row.map.with_index { |text, position| justify_cell(text, position) }
end
row_statements(indent=nil) click to toggle source
# File lib/cucumber/core/gherkin/writer/helpers.rb, line 148
def row_statements(indent=nil)
  rows.map { |row| indent(table_row(row), indent) }
end
table_row(row) click to toggle source
# File lib/cucumber/core/gherkin/writer/helpers.rb, line 152
def table_row(row)
  padded = pad(row)
  "| #{padded.join(' | ')} |"
end