Class: OoxmlParser::TableRow

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

Instance Attribute Summary collapse

Attributes inherited from OOXMLDocumentObject

#parent

Instance Method Summary collapse

Methods inherited from OOXMLDocumentObject

#==, add_to_xmls_stack, copy_file_and_rename_to_zip, current_xml, dir, encrypted_file?, get_link_from_rels, unzip_file, #with_data?

Methods included from OoxmlDocumentObjectHelper

#to_hash

Constructor Details

#initialize(cells = [], parent: nil) ⇒ TableRow

Returns a new instance of TableRow.



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

def initialize(cells = [], parent: nil)
  @cells = cells
  @parent = parent
end

Instance Attribute Details

#cellsObject

Returns the value of attribute cells.



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

def cells
  @cells
end

#heightObject Also known as: table_row_height

Returns the value of attribute height.



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

def height
  @height
end

#table_row_propertiesObject

Returns the value of attribute table_row_properties.



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

def table_row_properties
  @table_row_properties
end

Instance Method Details

#parse(node) ⇒ TableRow

Parse TableRow object

Parameters:

  • node to parse

Returns:

  • result of parsing



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/ooxml_parser/common_parser/common_data/table/row/row.rb', line 17

def parse(node)
  Presentation.current_font_style = FontStyle.new(true) # TODO: Add correct parsing of TableStyle.xml file and use it
  node.attributes.each do |key, value|
    case key
    when 'h'
      @height = OoxmlSize.new(value.value.to_f, :emu)
    end
  end
  node.xpath('*').each do |node_child|
    case node_child.name
    when 'trPr'
      @table_row_properties = TableRowProperties.new(parent: self).parse(node_child)
    when 'tc'
      @cells << TableCell.new(parent: self).parse(node_child)
    end
  end
  Presentation.current_font_style = FontStyle.new
  self
end