Class: OoxmlParser::PivotField

Inherits:
OOXMLDocumentObject show all
Defined in:
lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition/pivot_fields/pivot_field.rb

Overview

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

#axisString (readonly)

Returns axis value.

Returns:

  • (String)

    axis value



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

def axis
  @axis
end

#itemsItems (readonly)

Returns contain item.

Returns:

  • (Items)

    contain item



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

def items
  @items
end

#nameString (readonly)

Returns field name.

Returns:

  • (String)

    field name



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

def name
  @name
end

#show_allTrue, False (readonly)

Returns should show all.

Returns:

  • (True, False)

    should show all



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

def show_all
  @show_all
end

Instance Method Details

#parse(node) ⇒ PivotField

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

Returns:



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition/pivot_fields/pivot_field.rb', line 20

def parse(node)
  node.attributes.each do |key, value|
    case key
    when 'name'
      @name = value.value.to_s
    when 'axis'
      @axis = value.value.to_s
    when 'showAll'
      @show_all = attribute_enabled?(value)
    end
  end

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