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 cols = [] col_specs.each do |col_spec| total_width += col_spec['width'] cols << Column.new(self, cols.size, col_spec) end unless cols.empty? @attributes['colcount'] = cols.size even_width = (100.0 / cols.size).floor cols.each {|c| c.assign_width(total_width, even_width) } end @columns = cols nil end
def header_row?
Internal: Returns whether the current row being processed is
def header_row? @has_header_option && @rows.body.empty? end
def initialize parent, attributes
def initialize parent, attributes super parent, :table @rows = Rows.new @columns = [] @has_header_option = attributes.key? 'header-option' # 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 if @document.attributes.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 num_body_rows = @rows.body.size if num_body_rows > 0 && @has_header_option head = @rows.body.shift num_body_rows -= 1 # styles aren't applied to header row head.each {|c| c.style = nil } # 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 num_body_rows > 0 && attributes.key?('footer-option') @rows.foot = [@rows.body.pop] end nil end