Sha256: 4a3016b6123f6a87d9e300603ad161b11d7b4e15da461b69b10bd094627baee6
Contents?: true
Size: 1.41 KB
Versions: 24
Compression:
Stored size: 1.41 KB
Contents
# frozen_string_literal: true module FatTable # A subclass of Formatter for rendering the table as a Ruby Array of Arrays. # Each cell is formatted as a string in accordance with the formatting # directives. All footers are included as extra Arrays of the output. # AoaFormatter supports no +options+ class AoaFormatter < Formatter private def evaluate? true end def pre_table '[' end def post_table ']' end def pre_header(_widths) '' end def post_header(_widths) '' end def pre_row '[' end def pre_cell(_val) "'" end # Because the cell, after conversion to a single-quoted string will be # eval'ed, we need to escape any single-quotes (') that appear in the # string. def quote_cell(val) if val.match?(/'/) # Use a negative look-behind to only quote single-quotes that are not # already preceded by a backslash val.gsub(/(?<!\\)'/, "'" => "\\'") else val end end def post_cell "'" end def inter_cell ',' end def post_row "],\n" end def hline(_widths) "nil,\n" end def pre_group '' end def post_group '' end def pre_gfoot '' end def post_gfoot '' end def pre_foot '' end def post_foot '' end end end
Version data entries
24 entries across 24 versions & 1 rubygems