def format_row(cells, wrap_cells_to)
      row_height = ([wrap_cells_to, cells.map(&:size).max].compact.min || 1)

      subrows = (0...row_height).map do |subrow_index|
        subrow_components = cells.zip(column_registry.values).map do |cell, column|
          num_subcells = cell.size
          cell_truncated = (num_subcells > row_height)
          append_truncator = (cell_truncated && subrow_index + 1 == row_height)

          lpad = PADDING_CHARACTER * @column_padding
          rpad =
            if append_truncator && @column_padding != 0
              @truncation_indicator + PADDING_CHARACTER * (@column_padding - 1)
            else
              PADDING_CHARACTER * @column_padding
            end

          inner =
            if subrow_index < num_subcells
              cell[subrow_index]
            else
              PADDING_CHARACTER * column.width
            end

          "#{lpad}#{inner}#{rpad}"
        end

        surround_join(subrow_components, @vertical_rule_character)
      end

      join_lines(subrows)
    end
def format_row(cells, wrap_cells_to)
      row_height = ([wrap_cells_to, cells.map(&:size).max].compact.min || 1)

      subrows = (0...row_height).map do |subrow_index|
        subrow_components = cells.zip(column_registry.values).map do |cell, column|
          num_subcells = cell.size
          cell_truncated = (num_subcells > row_height)
          append_truncator = (cell_truncated && subrow_index + 1 == row_height)

          lpad = PADDING_CHARACTER * @column_padding
          rpad =
            if append_truncator && @column_padding != 0
              @truncation_indicator + PADDING_CHARACTER * (@column_padding - 1)
            else
              PADDING_CHARACTER * @column_padding
            end

          inner =
            if subrow_index < num_subcells
              cell[subrow_index]
            else
              PADDING_CHARACTER * column.width
            end

          "#{lpad}#{inner}#{rpad}"
        end

        surround_join(subrow_components, @vertical_rule_character)
      end

      join_lines(subrows)
    end
@!visibility private

 Formats a single header row or body row as a String.

 @param [String[][]] cells an Array of Array-of-Strings, each of which represents a
   "stack" of "subcells". Each such stack represents the wrapped content of a given
   "cell" in this row, from the top down, one String for each "line".
   Each String includes the spaces, if any, on either side required for the
   "internal padding" of the cell to carry out the cell content alignment -- but
   does not include the single character of padding around each column.
 @param [Integer] wrap_cells_to the number of "lines" of wrapped content to allow
   before truncating.
 @return [String] the entire formatted row including all padding and borders.