Sha256: 43f7cdd38bf738249bdc55de9f66b7d016244c1f242fb6cdf820f5eb6f2d781c

Contents?: true

Size: 1.23 KB

Versions: 1

Compression:

Stored size: 1.23 KB

Contents

# frozen_string_literal: true

module OoxmlParser
  # Class for parsing `formPr` tag
  class FormProperties < OOXMLDocumentObject
    # @return [String] field key
    attr_reader :key
    # @return [String] text of tooltip
    attr_reader :help_text
    # @return [True, False] specifies if field is required
    attr_reader :required
    # @return [Shade] shade of field
    attr_reader :shade
    # @return [BordersProperties] border of field
    attr_reader :border

    def initialize(parent: nil)
      @required = false
      super
    end

    # Parse FormProperties object
    # @param node [Nokogiri::XML:Element] node to parse
    # @return [FormProperties] result of parsing
    def parse(node)
      node.attributes.each do |key, value|
        case key
        when 'key'
          @key = value.value
        when 'helpText'
          @help_text = value.value
        when 'required'
          @required = option_enabled?(value)
        end
      end

      node.xpath('*').each do |node_child|
        case node_child.name
        when 'shd'
          @shade = Shade.new(parent: self).parse(node_child)
        when 'border'
          @border = BordersProperties.new(parent: self).parse(node_child)
        end
      end
      self
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ooxml_parser-0.33.0 lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/sdt/sdt_properties/form_properties.rb