class OoxmlParser::PivotFields

Class for parsing <pivotFields> tag

Attributes

count[R]

@return [Integer] count

pivot_field[R]

@return [Array<PivotField>] list of PivotField object

Public Class Methods

new(parent: nil) click to toggle source
Calls superclass method OoxmlParser::OOXMLDocumentObject::new
# File lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition/pivot_fields.rb, line 13
def initialize(parent: nil)
  @pivot_field = []
  super
end

Public Instance Methods

[](key) click to toggle source

@return [PivotField] accessor

# File lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition/pivot_fields.rb, line 19
def [](key)
  @pivot_field[key]
end
parse(node) click to toggle source

Parse ‘<pivotFields>` tag @param [Nokogiri::XML:Element] node with pivotFields data @return [PivotFields]

# File lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition/pivot_fields.rb, line 26
def parse(node)
  node.attributes.each do |key, value|
    case key
    when 'count'
      @count = value.value.to_i
    end
  end

  node.xpath('*').each do |node_child|
    case node_child.name
    when 'pivotField'
      @pivot_field << PivotField.new(parent: self).parse(node_child)
    end
  end
  self
end