class OoxmlParser::TableCell
Class for parsing ‘tc` tags
Attributes
cell_properties[RW]
elements[RW]
grid_span[RW]
horizontal_merge[RW]
properties[RW]
text_body[RW]
vertical_merge[RW]
Public Class Methods
new(parent: nil)
click to toggle source
Calls superclass method
OoxmlParser::OOXMLDocumentObject::new
# File lib/ooxml_parser/common_parser/common_data/table/row/cell/cell.rb, line 10 def initialize(parent: nil) @elements = [] super end
Public Instance Methods
parse(node)
click to toggle source
Parse TableCell
object @param node [Nokogiri::XML:Element] node to parse @return [TableCell] result of parsing
# File lib/ooxml_parser/common_parser/common_data/table/row/cell/cell.rb, line 20 def parse(node) node.attributes.each do |key, value| case key when 'gridSpan' @grid_span = value.value.to_i when 'hMerge' @horizontal_merge = value.value.to_i when 'vMerge' @vertical_merge = value.value.to_i end end node.xpath('*').each do |node_child| case node_child.name when 'txBody' @text_body = TextBody.new(parent: self).parse(node_child) when 'tcPr' @properties = CellProperties.new(parent: self).parse(node_child) when 'p' @elements << root_object.default_table_paragraph_style.dup.parse(node_child, 0, root_object.default_table_run_style, parent: self) when 'sdt' @elements << StructuredDocumentTag.new(parent: self).parse(node_child) when 'tbl' @elements << Table.new(parent: self).parse(node_child) end end self end