Class: Polytrix::Reports::MarkdownReporter

Inherits:
Object
  • Object
show all
Defined in:
lib/polytrix/reports/markdown_reporter.rb

Instance Method Summary collapse

Constructor Details

#initialize(io = $stdout) ⇒ MarkdownReporter

Returns a new instance of MarkdownReporter.



4
5
6
# File 'lib/polytrix/reports/markdown_reporter.rb', line 4

def initialize(io = $stdout)
  @buffer = io
end

Instance Method Details



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/polytrix/reports/markdown_reporter.rb', line 8

def print_table(table)
  @buffer.puts # Markdown tables don't always render properly without a break
  header_data = table[0]
  header_line = header_data.join ' | '
  @buffer.puts header_line
  @buffer.puts header_line.gsub(/[^|]/, '-')

  table[1..-1].each do |data_line|
    @buffer.puts data_line.join ' | '
  end
end