class Asciidoctor::Table::Column

Public: Methods to manage the columns of an AsciiDoc table. In particular, it keeps track of the column specs

Attributes

style[RW]

Public: Get/Set the Symbol style for this column.

Public Class Methods

new(table, index, attributes = {}) click to toggle source
Calls superclass method Asciidoctor::AbstractNode.new
# File lib/asciidoctor/table.rb, line 180
def initialize table, index, attributes = {}
  super table, :column
  @style = attributes['style']
  attributes['colnumber'] = index + 1
  attributes['width'] ||= 1
  attributes['halign'] ||= 'left'
  attributes['valign'] ||= 'top'
  update_attributes(attributes)
end

Public Instance Methods

assign_width(col_pcwidth, width_base = nil, pf = 10000.0) click to toggle source

Internal: Calculate and assign the widths (percentage and absolute) for this column

This method assigns the colpcwidth and colabswidth attributes.

returns the resolved colpcwidth value

# File lib/asciidoctor/table.rb, line 198
def assign_width col_pcwidth, width_base = nil, pf = 10000.0
  if width_base
    col_pcwidth = ((@attributes['width'].to_f / width_base) * 100 * pf).to_i / pf
    col_pcwidth = col_pcwidth.to_i if col_pcwidth.to_i == col_pcwidth
  end
  @attributes['colpcwidth'] = col_pcwidth
  if parent.attributes.key? 'tableabswidth'
    # FIXME calculate more accurately (only used in DocBook output)
    @attributes['colabswidth'] = ((col_pcwidth / 100.0) * parent.attributes['tableabswidth']).round
  end
  col_pcwidth
end