Class: PseudoHiki::TableRowParser::InlineElement::TableCellNode

Inherits:
InlineParser::InlineElement::InlineNode show all
Defined in:
lib/pseudohiki/inlineparser.rb,
lib/pseudohiki/inlineparser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTableCellNode

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_typeObject

Returns the value of attribute cell_type.



116
117
118
# File 'lib/pseudohiki/inlineparser.rb', line 116

def cell_type
  @cell_type
end

#colspanObject

Returns the value of attribute colspan.



116
117
118
# File 'lib/pseudohiki/inlineparser.rb', line 116

def colspan
  @colspan
end

#rowspanObject

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