Class: Asciidoctor::Table

Inherits:
AbstractBlock show all
Defined in:
lib/asciidoctor/table.rb

Overview

It supports all three of AsciiDoc’s table formats: psv, dsv and csv.

Defined Under Namespace

Classes: Cell, Column, ParserContext, Rows

Constant Summary collapse

DEFAULT_PRECISION =

precision of column widths

4

Constants included from Substitutors

Substitutors::CAN, Substitutors::CGI, Substitutors::DEL, Substitutors::ESC_R_SB, Substitutors::HighlightedPassSlotRx, Substitutors::PASS_END, Substitutors::PASS_START, Substitutors::PLUS, Substitutors::PassSlotRx, Substitutors::QuotedTextSniffRx, Substitutors::RS, Substitutors::R_SB, Substitutors::SUB_GROUPS, Substitutors::SUB_HINTS, Substitutors::SUB_OPTIONS, Substitutors::SpecialCharsRx, Substitutors::SpecialCharsTr

Instance Attribute Summary collapse

Attributes inherited from AbstractBlock

#blocks, #content_model, #level, #numeral, #source_location, #style, #subs

Attributes inherited from AbstractNode

#attributes, #context, #document, #id, #node_name, #parent

Instance Method Summary collapse

Methods inherited from AbstractBlock

#<<, #alt, #assign_caption, #block?, #blocks?, #captioned_title, #content, #context=, #convert, #file, #find_by, #inline?, #lineno, #list_marker_keyword, #next_adjacent_block, #number, #number=, #remove_sub, #sections, #sections?, #sub?, #title, #title=, #title?, #xreftext

Methods inherited from AbstractNode

#add_role, #attr, #attr?, #block?, #converter, #enabled_options, #generate_data_uri, #generate_data_uri_from_uri, #has_role?, #icon_uri, #image_uri, #inline?, #is_uri?, #media_uri, #normalize_asset_path, #normalize_system_path, #normalize_web_path, #option?, #read_asset, #read_contents, #reftext, #reftext?, #remove_attr, #remove_role, #role, #role=, #role?, #roles, #set_attr, #set_option, #update_attributes

Methods included from Substitutors

#apply_header_subs, #apply_normal_subs, #apply_reftext_subs, #apply_subs, #expand_subs, #extract_passthroughs, #highlight_source, #resolve_block_subs, #resolve_lines_to_highlight, #resolve_pass_subs, #resolve_subs, #restore_passthroughs, #sub_attributes, #sub_callouts, #sub_macros, #sub_post_replacements, #sub_quotes, #sub_replacements, #sub_source, #sub_specialchars

Methods included from Logging

#logger, #message_with_context

Constructor Details

#initialize(parent, attributes) ⇒ Table

Returns a new instance of Table.



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/asciidoctor/table.rb', line 56

def initialize parent, attributes
  super parent, :table
  @rows = Rows.new
  @columns = []

  @has_header_option = false

  # smells like we need a utility method here
  # to resolve an integer width from potential bogus input
  if (pcwidth = attributes['width'])
    if (pcwidth_intval = pcwidth.to_i) > 100 || pcwidth_intval < 1
      pcwidth_intval = 100 unless pcwidth_intval == 0 && (pcwidth == '0' || pcwidth == '0%')
    end
  else
    pcwidth_intval = 100
  end
  @attributes['tablepcwidth'] = pcwidth_intval

  if @document.attributes['pagewidth']
    @attributes['tableabswidth'] = (abswidth_val = (((pcwidth_intval / 100.0) * @document.attributes['pagewidth'].to_f).truncate DEFAULT_PRECISION)) == abswidth_val.to_i ? abswidth_val.to_i : abswidth_val
  end

  @attributes['orientation'] = 'landscape' if attributes['rotate-option']
end

Instance Attribute Details

#captionObject (readonly)

Get the caption for this table



54
55
56
# File 'lib/asciidoctor/table.rb', line 54

def caption
  @caption
end

#columnsObject

Get/Set the columns for this table



44
45
46
# File 'lib/asciidoctor/table.rb', line 44

def columns
  @columns
end

#has_header_optionObject

Boolean specifies whether this table has a header row



51
52
53
# File 'lib/asciidoctor/table.rb', line 51

def has_header_option
  @has_header_option
end

#rowsObject

Get/Set the Rows struct for this table (encapsulates head, foot and body rows)



48
49
50
# File 'lib/asciidoctor/table.rb', line 48

def rows
  @rows
end