Class: ClassMetrix::Formatters::Components::TableComponent::TableRenderer

Inherits:
Object
  • Object
show all
Defined in:
lib/class_metrix/formatters/components/table_component/table_renderer.rb

Instance Method Summary collapse

Constructor Details

#initialize(table_style: :standard, max_column_width: 50) ⇒ TableRenderer

Returns a new instance of TableRenderer.



8
9
10
11
# File 'lib/class_metrix/formatters/components/table_component/table_renderer.rb', line 8

def initialize(table_style: :standard, max_column_width: 50)
  @table_style = table_style
  @max_column_width = max_column_width
end

Instance Method Details

#render_table(headers, rows, column_widths) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/class_metrix/formatters/components/table_component/table_renderer.rb', line 13

def render_table(headers, rows, column_widths)
  output = [] # : Array[String]
  output << build_row(headers, column_widths)
  output << build_separator(column_widths)

  rows.each do |row|
    output << build_row(row, column_widths)
  end

  output
end