Sha256: 746e0c0500a9ee5b54e1575e31edb75b152f58dbd0a4f078f7146f1c05b98e69

Contents?: true

Size: 972 Bytes

Versions: 2

Compression:

Stored size: 972 Bytes

Contents

# frozen_string_literal: true

require_relative 'data_fields/data_field'

module OoxmlParser
  # Class for parsing <dataFields> tag
  class DataFields < OOXMLDocumentObject
    # @return [Integer] count
    attr_reader :count
    # @return [Array<DataField>] list of DataField object
    attr_reader :data_field

    def initialize(parent: nil)
      @data_field = []
      super
    end

    # @return [DataField] accessor
    def [](key)
      @data_field[key]
    end

    # Parse `<dataFields>` tag
    # @param [Nokogiri::XML:Element] node with dataFields data
    # @return [DataFields]
    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 'dataField'
          @data_field << DataField.new(parent: self).parse(node_child)
        end
      end
      self
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ooxml_parser-0.37.1 lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition/data_fields.rb
ooxml_parser-0.37.0 lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition/data_fields.rb