Class: PseudoHiki::TableRowParser::InlineElement::TableCellNode
- Inherits:
-
InlineParser::InlineElement::InlineNode
- Object
- InlineParser::Node
- InlineParser::InlineElement::InlineNode
- PseudoHiki::TableRowParser::InlineElement::TableCellNode
- Defined in:
- lib/pseudohiki/inlineparser.rb,
lib/pseudohiki/inlineparser.rb
Instance Attribute Summary collapse
-
#cell_type ⇒ Object
Returns the value of attribute cell_type.
-
#colspan ⇒ Object
Returns the value of attribute colspan.
-
#rowspan ⇒ Object
Returns the value of attribute rowspan.
Instance Method Summary collapse
-
#initialize ⇒ TableCellNode
constructor
A new instance of TableCellNode.
- #parse_cellspan(token_str) ⇒ Object
- #parse_first_token(orig_tokens) ⇒ Object
- #push(token) ⇒ Object
Constructor Details
#initialize ⇒ TableCellNode
Returns a new instance of TableCellNode.
118 119 120 121 |
# File 'lib/pseudohiki/inlineparser.rb', line 118 def initialize super @cell_type, @rowspan, @colspan = TD, 1, 1 end |
Instance Attribute Details
#cell_type ⇒ Object
Returns the value of attribute cell_type.
116 117 118 |
# File 'lib/pseudohiki/inlineparser.rb', line 116 def cell_type @cell_type end |
#colspan ⇒ Object
Returns the value of attribute colspan.
116 117 118 |
# File 'lib/pseudohiki/inlineparser.rb', line 116 def colspan @colspan end |
#rowspan ⇒ Object
Returns the value of attribute rowspan.
116 117 118 |
# File 'lib/pseudohiki/inlineparser.rb', line 116 def rowspan @rowspan end |
Instance Method Details
#parse_cellspan(token_str) ⇒ Object
130 131 132 133 134 135 136 137 |
# File 'lib/pseudohiki/inlineparser.rb', line 130 def parse_cellspan(token_str) m = MODIFIED_CELL_PAT.match(token_str) and cell_modifiers = m[0] return token_str if cell_modifiers.empty? @cell_type = TH if cell_modifiers.start_with? TH_PAT @rowspan = cell_modifiers.count(ROW_EXPANDER) + 1 @colspan = cell_modifiers.count(COL_EXPANDER) + 1 m.post_match end |
#parse_first_token(orig_tokens) ⇒ Object
139 140 141 142 |
# File 'lib/pseudohiki/inlineparser.rb', line 139 def parse_first_token(orig_tokens) return orig_tokens if orig_tokens.kind_of? InlineParser::InlineNode orig_tokens.dup.tap {|tokens| tokens[0] = parse_cellspan(tokens[0]) } end |
#push(token) ⇒ Object
144 145 146 147 |
# File 'lib/pseudohiki/inlineparser.rb', line 144 def push(token) return super(token) unless empty? super(parse_first_token(token)) end |