Class: OoxmlParser::PivotCacheDefinition
- Inherits:
-
OOXMLDocumentObject
- Object
- OOXMLDocumentObject
- OoxmlParser::PivotCacheDefinition
- Defined in:
- lib/ooxml_parser/xlsx_parser/workbook/pivot_cache/pivot_cache_definition.rb
Overview
Class for parsing <pivotCacheDefinition> file
Instance Attribute Summary collapse
-
#cache_fields ⇒ CacheFields
readonly
Fields of pivot cache.
-
#cache_source ⇒ CacheSource
readonly
Source of pivot cache.
-
#id ⇒ String
readonly
Id of pivot cache definition.
Attributes inherited from OOXMLDocumentObject
Instance Method Summary collapse
-
#parse(file) ⇒ PivotCacheDefinition
Parse PivotCacheDefinition file.
Methods inherited from OOXMLDocumentObject
#==, #boolean_attribute_value, #initialize, #parse_xml, #with_data?
Methods included from OoxmlObjectAttributeHelper
#attribute_enabled?, #option_enabled?
Methods included from OoxmlDocumentObjectHelper
Constructor Details
This class inherits a constructor from OoxmlParser::OOXMLDocumentObject
Instance Attribute Details
#cache_fields ⇒ CacheFields (readonly)
Returns fields of pivot cache.
14 15 16 |
# File 'lib/ooxml_parser/xlsx_parser/workbook/pivot_cache/pivot_cache_definition.rb', line 14 def cache_fields @cache_fields end |
#cache_source ⇒ CacheSource (readonly)
Returns source of pivot cache.
12 13 14 |
# File 'lib/ooxml_parser/xlsx_parser/workbook/pivot_cache/pivot_cache_definition.rb', line 12 def cache_source @cache_source end |
#id ⇒ String (readonly)
Returns id of pivot cache definition.
10 11 12 |
# File 'lib/ooxml_parser/xlsx_parser/workbook/pivot_cache/pivot_cache_definition.rb', line 10 def id @id end |
Instance Method Details
#parse(file) ⇒ PivotCacheDefinition
Parse PivotCacheDefinition file
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/ooxml_parser/xlsx_parser/workbook/pivot_cache/pivot_cache_definition.rb', line 19 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 |