Sha256: 8f278bbecf821d2616a38c955848605e934a4b4d4a7e67215f1d2b7d672261af

Contents?: true

Size: 884 Bytes

Versions: 37

Compression:

Stored size: 884 Bytes

Contents

# frozen_string_literal: true

require_relative 'items/item'

module OoxmlParser
  # Class for parsing <items> tag
  class Items < OOXMLDocumentObject
    # @return [Integer] count
    attr_reader :count
    # @return [Array<Item>] list of items
    attr_reader :items

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

    # @return [Item] accessor
    def [](key)
      @items[key]
    end

    # Parse `<items>` tag
    # @param [Nokogiri::XML:Element] node with items data
    # @return [Items]
    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 'item'
          @items << Item.new(parent: self).parse(node_child)
        end
      end
      self
    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
ooxml_parser-0.37.1 lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition/pivot_fields/pivot_field/items.rb
ooxml_parser-0.37.0 lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition/pivot_fields/pivot_field/items.rb
ooxml_parser-0.36.1 lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition/pivot_fields/pivot_field/items.rb
ooxml_parser-0.36.0 lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition/pivot_fields/pivot_field/items.rb
ooxml_parser-0.35.0 lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition/pivot_fields/pivot_field/items.rb
ooxml_parser-0.34.2 lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition/pivot_fields/pivot_field/items.rb
ooxml_parser-0.34.1 lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition/pivot_fields/pivot_field/items.rb
ooxml_parser-0.34.0 lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition/pivot_fields/pivot_field/items.rb
ooxml_parser-0.33.0 lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition/pivot_fields/pivot_field/items.rb
ooxml_parser-0.32.0 lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition/pivot_fields/pivot_field/items.rb
ooxml_parser-0.31.0 lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition/pivot_fields/pivot_field/items.rb
ooxml_parser-0.30.0 lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition/pivot_fields/pivot_field/items.rb
ooxml_parser-0.29.0 lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition/pivot_fields/pivot_field/items.rb
ooxml_parser-0.28.0 lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition/pivot_fields/pivot_field/items.rb
ooxml_parser-0.27.0 lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition/pivot_fields/pivot_field/items.rb
ooxml_parser-0.26.0 lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition/pivot_fields/pivot_field/items.rb
ooxml_parser-0.25.0 lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition/pivot_fields/pivot_field/items.rb
ooxml_parser-0.24.0 lib/ooxml_parser/xlsx_parser/workbook/pivot_table_definition/pivot_fields/pivot_field/items.rb
ooxml_parser-0.23.0 lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_table_definition/pivot_fields/pivot_field/items.rb
ooxml_parser-0.22.0 lib/ooxml_parser/xlsx_parser/xlsx_data/view_model/workbook/pivot_table_definition/pivot_fields/pivot_field/items.rb