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

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(parent: nil) ⇒ TableGrid

Returns a new instance of TableGrid.



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

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

Instance Attribute Details

#columnsArray, GridColumn

Returns array of columns.

Returns:



6
7
8
# File 'lib/ooxml_parser/common_parser/common_data/table/table_grid.rb', line 6

def columns
  @columns
end

Instance Method Details

#==(other) ⇒ Object



13
14
15
16
17
18
# File 'lib/ooxml_parser/common_parser/common_data/table/table_grid.rb', line 13

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:



23
24
25
26
27
28
29
30
31
# File 'lib/ooxml_parser/common_parser/common_data/table/table_grid.rb', line 23

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