class GrafanaReporter::Asciidoctor::AdocPlainTableFormatStrategy
Implements a default table format strategy, which will return tables as asciidoctor formatted table.
Public Class Methods
abbreviation()
click to toggle source
@see AbstractTableFormatStrategy#abbreviation
# File lib/grafana_reporter/asciidoctor/adoc_plain_table_format_strategy.rb, line 9 def self.abbreviation 'adoc_plain' end
Public Instance Methods
format(result, include_headline)
click to toggle source
@see AbstractTableFormatStrategy#format
# File lib/grafana_reporter/asciidoctor/adoc_plain_table_format_strategy.rb, line 14 def format(result, include_headline) headline = '| ' + result[:header].map { |item| item.to_s.gsub(' | ', '\\|') }.join(' | ') content = result[:content].map do |row| '| ' + row.map { |item| item.to_s.gsub(' | ', '\\|') }.join(' | ') end.join("\n") "#{"#{headline}\n" if include_headline}#{content}" end