Sha256: 1409adebea436e10ee70bd06fc13cc5e5d1f1c45aa8955edf44b3321793f26ae

Contents?: true

Size: 1.42 KB

Versions: 40

Compression:

Stored size: 1.42 KB

Contents

# frozen_string_literal: true

require_relative 'table/row/row'
require_relative 'table/table_properties'
require_relative 'table/table_grid'
require_relative 'table/margins/table_margins'
require_relative 'table/margins/paragraph_margins'
module OoxmlParser
  # Class for Table data
  class Table < OOXMLDocumentObject
    attr_accessor :grid, :rows, :properties, :number

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

    alias table_properties properties

    # @return [String] result of convert of object to string
    def to_s
      "Rows: #{@rows.join(',')}"
    end

    # @return [String] inspect of object for debug means
    def inspect
      to_s
    end

    # Parse Table object
    # @param node [Nokogiri::XML:Element] node to parse
    # @return [Table] result of parsing
    def parse(node,
              number = 0,
              default_table_properties = TableProperties.new)
      table_properties = default_table_properties.dup
      table_properties.jc = :left
      node.xpath('*').each do |node_child|
        case node_child.name
        when 'tblGrid'
          @grid = TableGrid.new(parent: self).parse(node_child)
        when 'tr'
          @rows << TableRow.new(parent: self).parse(node_child)
        when 'tblPr'
          @properties = TableProperties.new(parent: self).parse(node_child)
        end
      end
      @number = number
      self
    end
  end
end

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
ooxml_parser-0.37.1 lib/ooxml_parser/common_parser/common_data/table.rb
ooxml_parser-0.37.0 lib/ooxml_parser/common_parser/common_data/table.rb
ooxml_parser-0.36.1 lib/ooxml_parser/common_parser/common_data/table.rb
ooxml_parser-0.36.0 lib/ooxml_parser/common_parser/common_data/table.rb
ooxml_parser-0.35.0 lib/ooxml_parser/common_parser/common_data/table.rb
ooxml_parser-0.34.2 lib/ooxml_parser/common_parser/common_data/table.rb
ooxml_parser-0.34.1 lib/ooxml_parser/common_parser/common_data/table.rb
ooxml_parser-0.34.0 lib/ooxml_parser/common_parser/common_data/table.rb
ooxml_parser-0.33.0 lib/ooxml_parser/common_parser/common_data/table.rb
ooxml_parser-0.32.0 lib/ooxml_parser/common_parser/common_data/table.rb
ooxml_parser-0.31.0 lib/ooxml_parser/common_parser/common_data/table.rb
ooxml_parser-0.30.0 lib/ooxml_parser/common_parser/common_data/table.rb
ooxml_parser-0.29.0 lib/ooxml_parser/common_parser/common_data/table.rb
ooxml_parser-0.28.0 lib/ooxml_parser/common_parser/common_data/table.rb
ooxml_parser-0.27.0 lib/ooxml_parser/common_parser/common_data/table.rb
ooxml_parser-0.26.0 lib/ooxml_parser/common_parser/common_data/table.rb
ooxml_parser-0.25.0 lib/ooxml_parser/common_parser/common_data/table.rb
ooxml_parser-0.24.0 lib/ooxml_parser/common_parser/common_data/table.rb
ooxml_parser-0.23.0 lib/ooxml_parser/common_parser/common_data/table.rb
ooxml_parser-0.22.0 lib/ooxml_parser/common_parser/common_data/table.rb