Sha256: 510f7e9579ee79a914c58a1918413c84259228b58bd2fe1e332b7a4b8d3aec5b

Contents?: true

Size: 1.49 KB

Versions: 1

Compression:

Stored size: 1.49 KB

Contents

# frozen_string_literal: true

module OoxmlParser
  # Class for parsing `numPr` tags
  class NumberingProperties < OOXMLDocumentObject
    attr_accessor :size, :font, :symbol, :start_at, :type, :image
    # @return [ValuedChild] i level
    attr_reader :i_level
    # @return [ValuedChild] numbering id
    attr_reader :num_id

    def initialize(ilvl = 0, parent: nil)
      @ilvl = ilvl
      super(parent: parent)
    end

    # @return [AbstractNumbering] AbstractNumbering of current properties
    def abstruct_numbering
      root_object.numbering.properties_by_num_id(numbering_properties)
    end

    # Parse NumberingProperties
    # @param [Nokogiri::XML:Node] node with NumberingProperties
    # @return [NumberingProperties] result of parsing
    def parse(node)
      node.xpath('*').each do |node_child|
        case node_child.name
        when 'ilvl'
          @i_level = ValuedChild.new(:integer, parent: self).parse(node_child)
        when 'numId'
          @num_id = ValuedChild.new(:integer, parent: self).parse(node_child)
        end
      end
      self
    end

    # @return [Integer] numbering properties
    def numbering_properties
      @num_id.value
    end

    # @return [Integer] i-level value
    def ilvl
      @i_level.value
    end

    # @return [AbstractNumbering] level list of current numbering
    def numbering_level_current
      abstruct_numbering.level_list.each do |current_ilvl|
        return current_ilvl if current_ilvl.ilvl == @ilvl
      end
      nil
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ooxml_parser-0.34.0 lib/ooxml_parser/common_parser/common_data/paragraph/paragraph_properties/numbering_properties.rb