Class: OoxmlParser::TableCell

Inherits:
OOXMLDocumentObject show all
Defined in:
lib/ooxml_parser/common_parser/common_data/table/row/cell/cell.rb

Overview

Class for parsing ‘tc` tags

Instance Attribute Summary collapse

Attributes inherited from OOXMLDocumentObject

#parent

Instance Method Summary collapse

Methods inherited from OOXMLDocumentObject

#==, #boolean_attribute_value, #parse_xml, #with_data?

Methods included from OoxmlObjectAttributeHelper

#attribute_enabled?, #option_enabled?

Methods included from OoxmlDocumentObjectHelper

#to_hash

Constructor Details

#initialize(parent: nil) ⇒ TableCell

Returns a new instance of TableCell.



10
11
12
13
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/cell.rb', line 10

def initialize(parent: nil)
  @elements = []
  super
end

Instance Attribute Details

#elementsObject

Returns the value of attribute elements.



8
9
10
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/cell.rb', line 8

def elements
  @elements
end

#grid_spanObject

Returns the value of attribute grid_span.



8
9
10
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/cell.rb', line 8

def grid_span
  @grid_span
end

#horizontal_mergeObject

Returns the value of attribute horizontal_merge.



8
9
10
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/cell.rb', line 8

def horizontal_merge
  @horizontal_merge
end

#propertiesObject Also known as: cell_properties

Returns the value of attribute properties.



8
9
10
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/cell.rb', line 8

def properties
  @properties
end

#text_bodyObject

Returns the value of attribute text_body.



8
9
10
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/cell.rb', line 8

def text_body
  @text_body
end

#vertical_mergeObject

Returns the value of attribute vertical_merge.



8
9
10
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/cell.rb', line 8

def vertical_merge
  @vertical_merge
end

Instance Method Details

#parse(node) ⇒ TableCell

Parse TableCell object

Parameters:

  • node (Nokogiri::XML:Element)

    node to parse

Returns:



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# 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