Class: OoxmlParser::TableGrid

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

Overview

Class for parsing ‘w:tblGrid` object

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) ⇒ TableGrid

Returns a new instance of TableGrid.



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

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

Instance Attribute Details

#columnsArray, GridColumn

Returns array of columns.

Returns:



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

def columns
  @columns
end

Instance Method Details

#==(other) ⇒ True, False

Compare this object to other

Parameters:

  • other (Object)

    any other object

Returns:

  • (True, False)

    result of comparision



18
19
20
21
22
23
# File 'lib/ooxml_parser/common_parser/common_data/table/table_grid.rb', line 18

def ==(other)
  @columns.each_with_index do |cur_column, index|
    return false unless cur_column == other.columns[index]
  end
  true
end

#parse(node) ⇒ TableGrid

Parse TableGrid

Parameters:

  • node (Nokogiri::XML:Node)

    with TableGrid

Returns:



28
29
30
31
32
33
34
35
36
# File 'lib/ooxml_parser/common_parser/common_data/table/table_grid.rb', line 28

def parse(node)
  node.xpath('*').each do |grid_child|
    case grid_child.name
    when 'gridCol'
      @columns << GridColumn.new(parent: self).parse(grid_child)
    end
  end
  self
end