Sha256: c8c60b45f580c41fb03c362b41e730962629075e3e86d45b74b54617d2d615aa

Contents?: true

Size: 1021 Bytes

Versions: 1

Compression:

Stored size: 1021 Bytes

Contents

# frozen_string_literal: true

require_relative 'pivot_field/items'

module OoxmlParser
  # Class for parsing <pivotField> tag
  class PivotField < OOXMLDocumentObject
    # @return [String] field name
    attr_reader :name
    # @return [String] axis value
    attr_reader :axis
    # @return [True, False] should show all
    attr_reader :show_all
    # @return [Items] contain item
    attr_reader :items

    # Parse `<pivotField>` tag
    # # @param [Nokogiri::XML:Element] node with PivotField data
    # @return [PivotField]
    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
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ooxml_parser-0.37.1 lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition/pivot_fields/pivot_field.rb