Sha256: 09b4d7a429056122492b90d0efdfb75b88196c7870c275559a50c20f3d67a18b

Contents?: true

Size: 1.18 KB

Versions: 37

Compression:

Stored size: 1.18 KB

Contents

# frozen_string_literal: true

require_relative 'pivot_cache_definition/cache_source'
require_relative 'pivot_cache_definition/cache_fields'

module OoxmlParser
  # Class for parsing <pivotCacheDefinition> file
  class PivotCacheDefinition < OOXMLDocumentObject
    # @return [String] id of pivot cache definition
    attr_reader :id
    # @return [CacheSource] source of pivot cache
    attr_reader :cache_source
    # @return [CacheFields] fields of pivot cache
    attr_reader :cache_fields

    # Parse PivotCacheDefinition file
    # @param file [String] path to file
    # @return [PivotCacheDefinition]
    def parse(file)
      return nil unless File.exist?(file)

      document = parse_xml(file)
      node = document.xpath('*').first

      node.attributes.each do |key, value|
        case key
        when 'id'
          @id = value.value.to_s
        end
      end

      node.xpath('*').each do |node_child|
        case node_child.name
        when 'cacheSource'
          @cache_source = CacheSource.new(parent: self).parse(node_child)
        when 'cacheFields'
          @cache_fields = CacheFields.new(parent: self).parse(node_child)
        end
      end
      self
    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
ooxml_parser-0.37.1 lib/ooxml_parser/xlsx_parser/workbook/pivot_cache/pivot_cache_definition.rb
ooxml_parser-0.37.0 lib/ooxml_parser/xlsx_parser/workbook/pivot_cache/pivot_cache_definition.rb
ooxml_parser-0.36.1 lib/ooxml_parser/xlsx_parser/workbook/pivot_cache/pivot_cache_definition.rb
ooxml_parser-0.36.0 lib/ooxml_parser/xlsx_parser/workbook/pivot_cache/pivot_cache_definition.rb
ooxml_parser-0.35.0 lib/ooxml_parser/xlsx_parser/workbook/pivot_cache/pivot_cache_definition.rb
ooxml_parser-0.34.2 lib/ooxml_parser/xlsx_parser/workbook/pivot_cache/pivot_cache_definition.rb
ooxml_parser-0.34.1 lib/ooxml_parser/xlsx_parser/workbook/pivot_cache/pivot_cache_definition.rb
ooxml_parser-0.34.0 lib/ooxml_parser/xlsx_parser/workbook/pivot_cache/pivot_cache_definition.rb
ooxml_parser-0.33.0 lib/ooxml_parser/xlsx_parser/workbook/pivot_cache/pivot_cache_definition.rb
ooxml_parser-0.32.0 lib/ooxml_parser/xlsx_parser/workbook/pivot_cache/pivot_cache_definition.rb
ooxml_parser-0.31.0 lib/ooxml_parser/xlsx_parser/workbook/pivot_cache/pivot_cache_definition.rb
ooxml_parser-0.30.0 lib/ooxml_parser/xlsx_parser/workbook/pivot_cache/pivot_cache_definition.rb
ooxml_parser-0.29.0 lib/ooxml_parser/xlsx_parser/workbook/pivot_cache/pivot_cache_definition.rb
ooxml_parser-0.28.0 lib/ooxml_parser/xlsx_parser/workbook/pivot_cache/pivot_cache_definition.rb
ooxml_parser-0.27.0 lib/ooxml_parser/xlsx_parser/workbook/pivot_cache/pivot_cache_definition.rb
ooxml_parser-0.26.0 lib/ooxml_parser/xlsx_parser/workbook/pivot_cache/pivot_cache_definition.rb
ooxml_parser-0.25.0 lib/ooxml_parser/xlsx_parser/workbook/pivot_cache/pivot_cache_definition.rb
ooxml_parser-0.24.0 lib/ooxml_parser/xlsx_parser/workbook/pivot_cache/pivot_cache_definition.rb
ooxml_parser-0.23.0 lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_cache/pivot_cache_definition.rb
ooxml_parser-0.22.0 lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_cache/pivot_cache_definition.rb