Sha256: d0d141085ecb2c8dc81fe23a571310f6c4034e3de60e01e9ee888f55cb9f0033

Contents?: true

Size: 984 Bytes

Versions: 41

Compression:

Stored size: 984 Bytes

Contents

# frozen_string_literal: true

module OoxmlParser
  # Class for parsing `w:fldSimple` tags
  class FieldSimple < OOXMLDocumentObject
    # @return [String] instruction value
    attr_reader :instruction
    # @return [Array<ParagraphRun>] instruction value
    attr_reader :runs

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

    # Parse FieldSimple object
    # @param node [Nokogiri::XML:Element] node to parse
    # @return [FieldSimple] result of parsing
    def parse(node)
      node.attributes.each do |key, value|
        case key
        when 'instr'
          @instruction = value.value.to_s
        end
      end

      node.xpath('*').each do |node_child|
        case node_child.name
        when 'r'
          @runs << ParagraphRun.new(parent: self).parse(node_child)
        end
      end
      self
    end

    # @return [True, False] is field simple page numbering
    def page_numbering?
      instruction.include?('PAGE')
    end
  end
end

Version data entries

41 entries across 41 versions & 1 rubygems

Version Path
ooxml_parser-0.38.0 lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/field_simple.rb
ooxml_parser-0.37.1 lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/field_simple.rb
ooxml_parser-0.37.0 lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/field_simple.rb
ooxml_parser-0.36.1 lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/field_simple.rb
ooxml_parser-0.36.0 lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/field_simple.rb
ooxml_parser-0.35.0 lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/field_simple.rb
ooxml_parser-0.34.2 lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/field_simple.rb
ooxml_parser-0.34.1 lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/field_simple.rb
ooxml_parser-0.34.0 lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/field_simple.rb
ooxml_parser-0.33.0 lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/field_simple.rb
ooxml_parser-0.32.0 lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/field_simple.rb
ooxml_parser-0.31.0 lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/field_simple.rb
ooxml_parser-0.30.0 lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/field_simple.rb
ooxml_parser-0.29.0 lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/field_simple.rb
ooxml_parser-0.28.0 lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/field_simple.rb
ooxml_parser-0.27.0 lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/field_simple.rb
ooxml_parser-0.26.0 lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/field_simple.rb
ooxml_parser-0.25.0 lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/field_simple.rb
ooxml_parser-0.24.0 lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/field_simple.rb
ooxml_parser-0.23.0 lib/ooxml_parser/docx_parser/docx_data/document_structure/docx_paragraph/field_simple.rb