Sha256: 074f8c4fdb0ceab50a829de800cb9dca646ae9418549d09c487d1723b74a7d63

Contents?: true

Size: 1.26 KB

Versions: 13

Compression:

Stored size: 1.26 KB

Contents

# frozen_string_literal: true

require_relative 'pivot_cache/pivot_cache_definition'

module OoxmlParser
  # Class for parsing <pivotCache> tag
  class PivotCache < OOXMLDocumentObject
    # @return [Integer] cacheId of pivot cache
    attr_reader :cache_id
    # @return [String] id of pivot cache
    attr_reader :id
    # @return [PivotCacheDefinition] parsed pivot cache definition
    attr_reader :pivot_cache_definition

    # Parse Pivot Cache data
    # @param [Nokogiri::XML:Element] node with Pivot Cache data
    # @return [PivotCache] value of PivotCache
    def parse(node)
      node.attributes.each do |key, value|
        case key
        when 'cacheId'
          @cache_id = value.value.to_i
        when 'id'
          @id = value.value.to_s
        end
      end
      parse_pivot_cache_definition
      self
    end

    private

    # @return [PivotCacheDefinition] pivot cache definition for current pivot cache
    def parse_pivot_cache_definition
      definition_file = root_object.relationships.target_by_id(id)
      full_file_path = "#{root_object.unpacked_folder}/xl/#{definition_file}"
      @pivot_cache_definition = PivotCacheDefinition.new(parent: root_object)
                                                    .parse(full_file_path)
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
ooxml_parser-0.38.0 lib/ooxml_parser/xlsx_parser/workbook/pivot_cache.rb
ooxml_parser-0.37.1 lib/ooxml_parser/xlsx_parser/workbook/pivot_cache.rb
ooxml_parser-0.37.0 lib/ooxml_parser/xlsx_parser/workbook/pivot_cache.rb
ooxml_parser-0.36.1 lib/ooxml_parser/xlsx_parser/workbook/pivot_cache.rb
ooxml_parser-0.36.0 lib/ooxml_parser/xlsx_parser/workbook/pivot_cache.rb
ooxml_parser-0.35.0 lib/ooxml_parser/xlsx_parser/workbook/pivot_cache.rb
ooxml_parser-0.34.2 lib/ooxml_parser/xlsx_parser/workbook/pivot_cache.rb
ooxml_parser-0.34.1 lib/ooxml_parser/xlsx_parser/workbook/pivot_cache.rb
ooxml_parser-0.34.0 lib/ooxml_parser/xlsx_parser/workbook/pivot_cache.rb
ooxml_parser-0.33.0 lib/ooxml_parser/xlsx_parser/workbook/pivot_cache.rb
ooxml_parser-0.32.0 lib/ooxml_parser/xlsx_parser/workbook/pivot_cache.rb
ooxml_parser-0.31.0 lib/ooxml_parser/xlsx_parser/workbook/pivot_cache.rb
ooxml_parser-0.30.0 lib/ooxml_parser/xlsx_parser/workbook/pivot_cache.rb