class Asciidoctor::Table
It supports all three of AsciiDoc’s table formats: psv, dsv and csv.
Public: Methods and constants for managing AsciiDoc table content in a document.
def create_columns(col_specs)
Internal: Creates the Column objects from the column spec
def create_columns(col_specs) total_width = 0 @columns = col_specs.inject([]) {|collector, col_spec| total_width += col_spec['width'] collector << Column.new(self, collector.size, col_spec) collector } if !@columns.empty? @attributes['colcount'] = @columns.size even_width = (100.0 / @columns.size).floor @columns.each {|c| c.assign_width(total_width, even_width) } end nil end
def initialize(parent, attributes)
def initialize(parent, attributes) super(parent, :table) # QUESTION since caption is on block, should it go to AbstractBlock? @caption = nil @rows = Rows.new([], [], []) @columns = [] unless @attributes.has_key? 'tablepcwidth' # smell like we need a utility method here # to resolve an integer width from potential bogus input pcwidth = attributes['width'] pcwidth_intval = pcwidth.to_i.abs if pcwidth_intval == 0 && pcwidth != "0" || pcwidth_intval > 100 pcwidth_intval = 100 end @attributes['tablepcwidth'] = pcwidth_intval end if @document.attributes.has_key? 'pagewidth' @attributes['tableabswidth'] ||= ((@attributes['tablepcwidth'].to_f / 100) * @document.attributes['pagewidth']).round end end
def partition_header_footer(attributes)
by the options on the table
Internal: Partition the rows into header, footer and body as determined
def partition_header_footer(attributes) # set rowcount before splitting up body rows @attributes['rowcount'] = @rows.body.size if !rows.body.empty? && attributes.has_key?('header-option') head = rows.body.shift # styles aren't applied to header row head.each {|c| c.attributes.delete('style') } # QUESTION why does AsciiDoc use an array for head? is it # possible to have more than one based on the syntax? rows.head = [head] end if !rows.body.empty? && attributes.has_key?('footer-option') rows.foot = [rows.body.pop] end nil end
def render
rendered and returned as content that can be included in the
has child blocks, the content method should cause them to be
Public: Get the rendered String content for this Block. If the block
def render Asciidoctor.debug { "Now attempting to render for table my own bad #{self}" } Asciidoctor.debug { "Parent is #{@parent}" } Asciidoctor.debug { "Renderer is #{renderer}" } renderer.render('block_table', self) end