Class: OoxmlParser::TableRow

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

Overview

Class for data of TableRow

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(cells = [], parent: nil) ⇒ TableRow

Returns a new instance of TableRow.



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

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

Instance Attribute Details

#cellsObject

Returns the value of attribute cells.



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

def cells
  @cells
end

#heightObject Also known as: table_row_height

Returns the value of attribute height.



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

def height
  @height
end

#table_row_propertiesObject

Returns the value of attribute table_row_properties.



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

def table_row_properties
  @table_row_properties
end

Instance Method Details

#parse(node) ⇒ TableRow

Parse TableRow 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
# File 'lib/ooxml_parser/common_parser/common_data/table/row/row.rb', line 20

def parse(node)
  root_object.default_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
  root_object.default_font_style = FontStyle.new
  self
end