Class: OoxmlParser::FormProperties

Inherits:
OOXMLDocumentObject show all
Defined in:
lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/sdt/sdt_properties/form_properties.rb

Overview

Class for parsing ‘formPr` tag

Instance Attribute Summary collapse

Attributes inherited from OOXMLDocumentObject

#parent

Instance Method Summary collapse

Methods inherited from OOXMLDocumentObject

#==, #boolean_attribute_value, #parse_xml, #with_data?

Methods included from OoxmlObjectAttributeHelper

#attribute_enabled?, #option_enabled?

Methods included from OoxmlDocumentObjectHelper

#to_hash

Constructor Details

#initialize(parent: nil) ⇒ FormProperties

Returns a new instance of FormProperties.



17
18
19
20
# File 'lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/sdt/sdt_properties/form_properties.rb', line 17

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

Instance Attribute Details

#borderBordersProperties (readonly)

Returns border of field.

Returns:



15
16
17
# File 'lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/sdt/sdt_properties/form_properties.rb', line 15

def border
  @border
end

#help_textString (readonly)

Returns text of tooltip.

Returns:

  • (String)

    text of tooltip



9
10
11
# File 'lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/sdt/sdt_properties/form_properties.rb', line 9

def help_text
  @help_text
end

#keyString (readonly)

Returns field key.

Returns:

  • (String)

    field key



7
8
9
# File 'lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/sdt/sdt_properties/form_properties.rb', line 7

def key
  @key
end

#requiredTrue, False (readonly)

Returns specifies if field is required.

Returns:

  • (True, False)

    specifies if field is required



11
12
13
# File 'lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/sdt/sdt_properties/form_properties.rb', line 11

def required
  @required
end

#shadeShade (readonly)

Returns shade of field.

Returns:

  • (Shade)

    shade of field



13
14
15
# File 'lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/sdt/sdt_properties/form_properties.rb', line 13

def shade
  @shade
end

Instance Method Details

#parse(node) ⇒ FormProperties

Parse FormProperties object

Parameters:

  • node (Nokogiri::XML:Element)

    node to parse

Returns:



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/sdt/sdt_properties/form_properties.rb', line 25

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 = boolean_attribute_value(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