Class: OoxmlParser::DataField

Inherits:
OOXMLDocumentObject show all
Defined in:
lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition/data_fields/data_field.rb

Overview

Class for parsing <dataField> 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

#base_fieldInteger

Returns index of the base field for the ShowDataAs calculation.

Returns:

  • (Integer)

    index of the base field for the ShowDataAs calculation



7
8
9
# File 'lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition/data_fields/data_field.rb', line 7

def base_field
  @base_field
end

#base_itemInteger

Returns index of the base item for the ShowDataAs calculation.

Returns:

  • (Integer)

    index of the base item for the ShowDataAs calculation



9
10
11
# File 'lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition/data_fields/data_field.rb', line 9

def base_item
  @base_item
end

#extension_listExtensionList

Returns list of extensions.

Returns:



17
18
19
# File 'lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition/data_fields/data_field.rb', line 17

def extension_list
  @extension_list
end

#fieldInteger

Returns index of the field in the pivotCacheRecords.

Returns:

  • (Integer)

    index of the field in the pivotCacheRecords



11
12
13
# File 'lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition/data_fields/data_field.rb', line 11

def field
  @field
end

#nameString (readonly)

Returns name of the data field.

Returns:

  • (String)

    name of the data field



13
14
15
# File 'lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition/data_fields/data_field.rb', line 13

def name
  @name
end

#number_format_idInteger

Returns index of the number format applied to data field.

Returns:

  • (Integer)

    index of the number format applied to data field



15
16
17
# File 'lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition/data_fields/data_field.rb', line 15

def number_format_id
  @number_format_id
end

Instance Method Details

#parse(node) ⇒ DataField

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

Returns:



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition/data_fields/data_field.rb', line 22

def parse(node)
  node.attributes.each do |key, value|
    case key
    when 'baseField'
      @base_field = value.value.to_i
    when 'baseItem'
      @base_item = value.value.to_i
    when 'fld'
      @field = value.value.to_i
    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 'extLst'
      @extension_list = ExtensionList.new(parent: self).parse(node_child)
    end
  end
  self
end