Class: Charming::Markdown::TableRenderer

Inherits:
Object
  • Object
show all
Defined in:
lib/charming/presentation/markdown/table_renderer.rb

Overview

TableRenderer formats parsed Markdown table rows for terminal display.

Instance Method Summary collapse

Constructor Details

#initialize(rows:, style:) ⇒ TableRenderer

Returns a new instance of TableRenderer.



7
8
9
10
# File 'lib/charming/presentation/markdown/table_renderer.rb', line 7

def initialize(rows:, style:)
  @rows = rows
  @style = style
end

Instance Method Details

#renderObject



12
13
14
15
16
# File 'lib/charming/presentation/markdown/table_renderer.rb', line 12

def render
  return "" if rows.empty?

  rows.each_with_index.map { |row, index| render_row(row, index) }.join("\n")
end