Class: OoxmlParser::TableCell

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

Constant Summary

Constants inherited from OOXMLDocumentObject

OOXMLDocumentObject::DEFAULT_DIRECTORY_FOR_MEDIA

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from OOXMLDocumentObject

#==, add_to_xmls_stack, copy_file_and_rename_to_zip, copy_media_file, current_xml, dir, encrypted_file?, get_link_from_rels, media_folder, option_enabled?, unzip_file

Constructor Details

#initialize(text_body = nil) ⇒ TableCell

Returns a new instance of TableCell.



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

def initialize(text_body = nil)
  @text_body = text_body
  @elements = []
end

Instance Attribute Details

#elementsObject

Returns the value of attribute elements.



5
6
7
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/cell.rb', line 5

def elements
  @elements
end

#grid_spanObject

Returns the value of attribute grid_span.



5
6
7
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/cell.rb', line 5

def grid_span
  @grid_span
end

#horizontal_mergeObject

Returns the value of attribute horizontal_merge.



5
6
7
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/cell.rb', line 5

def horizontal_merge
  @horizontal_merge
end

#propertiesObject Also known as: cell_properties

Returns the value of attribute properties.



5
6
7
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/cell.rb', line 5

def properties
  @properties
end

#text_bodyObject

Returns the value of attribute text_body.



5
6
7
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/cell.rb', line 5

def text_body
  @text_body
end

#vertical_mergeObject

Returns the value of attribute vertical_merge.



5
6
7
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/cell.rb', line 5

def vertical_merge
  @vertical_merge
end

Class Method Details

.parse(cell_node) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/ooxml_parser/common_parser/common_data/table/row/cell/cell.rb', line 14

def self.parse(cell_node)
  cell = TableCell.new
  cell_node.xpath('*').each do |cell_node_child|
    case cell_node_child.name
    when 'txBody'
      cell.text_body = TextBody.parse(cell_node_child)
    when 'tcPr'
      cell.properties = CellProperties.parse(cell_node_child)
    when 'p'
      paragraph = DocxParagraph.parse(cell_node_child, 0, DocumentStructure.default_table_paragraph_style, DocumentStructure.default_table_run_style)
      cell.elements << paragraph
    when 'tbl'
      table = Table.parse(cell_node_child)
      cell.elements << table
    end
  end
  cell_node.attributes.each do |key, value|
    case key
    when 'gridSpan'
      cell.grid_span = value.value.to_i
    when 'hMerge'
      cell.horizontal_merge = value.value.to_i
    when 'vMerge'
      cell.vertical_merge = value.value.to_i
    end
  end
  cell
end