Class: OoxmlParser::CheckBox

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

Overview

Class for parsing ‘checkbox` tag

Instance Attribute Summary collapse

Attributes inherited from OOXMLDocumentObject

#parent

Instance Method Summary collapse

Methods inherited from OOXMLDocumentObject

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

Methods included from OoxmlObjectAttributeHelper

#attribute_enabled?, #option_enabled?

Methods included from OoxmlDocumentObjectHelper

#to_hash

Constructor Details

This class inherits a constructor from OoxmlParser::OOXMLDocumentObject

Instance Attribute Details

#checkedTrue, False (readonly)

Returns specifies if checkbox is checked.

Returns:

  • (True, False)

    specifies if checkbox is checked



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

def checked
  @checked
end

#checked_stateCheckBoxState (readonly)

Returns options of checked state.

Returns:



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

def checked_state
  @checked_state
end

#group_keyValuedChild (readonly)

Returns group key.

Returns:



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

def group_key
  @group_key
end

#unchecked_stateCheckBoxState (readonly)

Returns options of unchecked state.

Returns:



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

def unchecked_state
  @unchecked_state
end

Instance Method Details

#parse(node) ⇒ CheckBox

Parse CheckBox object

Parameters:

  • node (Nokogiri::XML:Element)

    node to parse

Returns:



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/sdt/sdt_properties/checkbox.rb', line 19

def parse(node)
  node.xpath('*').each do |node_child|
    case node_child.name
    when 'checked'
      @checked = option_enabled?(node_child, 'hidden')
    when 'checkedState'
      @checked_state = CheckBoxState.new(parent: self).parse(node_child)
    when 'uncheckedState'
      @unchecked_state = CheckBoxState.new(parent: self).parse(node_child)
    when 'groupKey'
      @group_key = ValuedChild.new(:string, parent: self).parse(node_child)
    end
  end
  self
end