Sha256: dcef8d31afee474a5c1a76a8a20d2feb64bf6530255162e21f34158b5a0147c4

Contents?: true

Size: 925 Bytes

Versions: 3

Compression:

Stored size: 925 Bytes

Contents

# frozen_string_literal: true

require_relative 'row_fields/field'

module OoxmlParser
  # Class for parsing <rowFields> tag
  class RowFields < OOXMLDocumentObject
    # @return [Integer] count
    attr_reader :count
    # @return [Array<Field>] list of Field object
    attr_reader :fields

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

    # @return [Field] accessor
    def [](key)
      @fields[key]
    end

    # Parse `<rowFields>` tag
    # @param [Nokogiri::XML:Element] node with rowFields data
    # @return [RowFields]
    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 'field'
          @fields << Field.new(parent: self).parse(node_child)
        end
      end
      self
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

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