class Paru::PandocFilter::ColSpec

ColSpec represents a colspec definition for a table column. It contains an alignment and the column’s width.

@see hackage.haskell.org/package/pandoc-types-1.21/docs/Text-Pandoc-Definition.html#t:ColSpec

@!attribute alignment

@return [String]

@!attribute width

@return [Double|COL_WIDTH_DEFAULT]

Attributes

alignment[R]
width[R]

Public Class Methods

new(contents = DEFAULT_COLSPEC) click to toggle source

Create a new ColSpec object

@param contents [Array = DEFAULT_COLSPEC] the attributes as a pair of [alignment, width]

# File lib/paru/filter/col_spec.rb, line 48
def initialize(contents = DEFAULT_COLSPEC)
    @alignment = Value.new contents[0]
    @width = Value.new contents[1]
end

Public Instance Methods

alignment=(new_alignment) click to toggle source

Set the alignment

@param [String] new_alignment the new alignment.

# File lib/paru/filter/col_spec.rb, line 68
def alignment=(new_alignment)
    @alignment.value = new_alignment
end
to_ast() click to toggle source

Convert this attributes object to an AST representation

@return [Array] Array containing id, class name list, and

key-value pair list
# File lib/paru/filter/col_spec.rb, line 76
def to_ast
    [
      @alignment.to_ast,
      @width.to_ast
    ]
end
width=(new_width) click to toggle source

Set the width

@param [String|Integer|Float] new_width the new width. If it is “ColWidthDefault”, it uses the default value.

# File lib/paru/filter/col_spec.rb, line 57
def width=(new_width)
    if new_width == "ColWidthDefault" then
        @width = Value.new({"t" => new_width})
    else
        @width = Value.new({"t" => "ColWidth", "c" => new_width})
    end
end