class Samovar::Output::Columns

Calculates the maximum width of each column across all rows for proper text alignment.
Represents column widths for aligned output formatting.

def calculate_widths(rows)

@returns [Array(Integer)] The maximum width of each column.
@parameter rows [Array(Array)] The rows to analyze.

Calculate the maximum width for each column.
def calculate_widths(rows)
	widths = []
	
	rows.each do |row|
		row.each.with_index do |column, index|
			(widths[index] ||= []) << column.size
		end
	end
	
	return widths.collect(&:max)
end

def initialize(rows)

@parameter rows [Array(Array)] The rows to calculate column widths from.

Initialize column width calculator.
def initialize(rows)
	@rows = rows
	@widths = calculate_widths(rows)
end