Class: OoxmlParser::CacheField

Inherits:
OOXMLDocumentObject show all
Defined in:
lib/ooxml_parser/xlsx_parser/workbook/pivot_cache/pivot_cache_definition/cache_fields/cache_field.rb

Overview

Class for parsing <cacheField> tag

Instance Attribute Summary collapse

Attributes inherited from OOXMLDocumentObject

#parent

Instance Method Summary collapse

Methods inherited from OOXMLDocumentObject

#==, #boolean_attribute_value, #initialize, #parse_xml, #with_data?

Methods included from OoxmlObjectAttributeHelper

#attribute_enabled?, #option_enabled?

Methods included from OoxmlDocumentObjectHelper

#to_hash

Constructor Details

This class inherits a constructor from OoxmlParser::OOXMLDocumentObject

Instance Attribute Details

#nameString (readonly)

Returns name of field.

Returns:

  • (String)

    name of field



9
10
11
# File 'lib/ooxml_parser/xlsx_parser/workbook/pivot_cache/pivot_cache_definition/cache_fields/cache_field.rb', line 9

def name
  @name
end

#number_format_idInteger (readonly)

Returns number format id.

Returns:

  • (Integer)

    number format id



11
12
13
# File 'lib/ooxml_parser/xlsx_parser/workbook/pivot_cache/pivot_cache_definition/cache_fields/cache_field.rb', line 11

def number_format_id
  @number_format_id
end

#shared_itemsSharedItems (readonly)

Returns shared items.

Returns:



13
14
15
# File 'lib/ooxml_parser/xlsx_parser/workbook/pivot_cache/pivot_cache_definition/cache_fields/cache_field.rb', line 13

def shared_items
  @shared_items
end

Instance Method Details

#parse(node) ⇒ CacheField

Parse ‘<cacheField>` tag # @param [Nokogiri::XML:Element] node with WorksheetSource data

Returns:



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/ooxml_parser/xlsx_parser/workbook/pivot_cache/pivot_cache_definition/cache_fields/cache_field.rb', line 18

def parse(node)
  node.attributes.each do |key, value|
    case key
    when 'name'
      @name = value.value.to_s
    when 'numFmtId'
      @number_format_id = value.value.to_i
    end
  end

  node.xpath('*').each do |node_child|
    case node_child.name
    when 'sharedItems'
      @shared_items = SharedItems.new(parent: self).parse(node_child)
    end
  end
  self
end