Module: OoxmlParser::OoxmlObjectAttributeHelper

Included in:
OOXMLDocumentObject
Defined in:
lib/ooxml_parser/common_parser/common_data/ooxml_document_object/ooxml_object_attribute_helper.rb

Overview

Module for stroing some attribute helpers for objects

Instance Method Summary collapse

Instance Method Details

#attribute_enabled?(node, attribute_name = 'val') ⇒ True, False

Returns is attribute enabled.

Parameters:

  • node (Nokogiri::XML:Element)

    node to parse

  • attribute_name (String) (defaults to: 'val')

    name of attribute

Returns:

  • (True, False)

    is attribute enabled



22
23
24
25
26
27
28
29
# File 'lib/ooxml_parser/common_parser/common_data/ooxml_document_object/ooxml_object_attribute_helper.rb', line 22

def attribute_enabled?(node, attribute_name = 'val')
  return true if node.to_s == '1'
  return false if node.to_s == '0'
  return false if node.attribute(attribute_name).nil?

  status = node.attribute(attribute_name).value
  %w[true on 1].include?(status)
end

#option_enabled?(node, attribute_name = 'val') ⇒ True, False

Returns is option enabled.

Parameters:

  • node (Nokogiri::XML:Element)

    node to parse

  • attribute_name (String) (defaults to: 'val')

    name of attribute

Returns:

  • (True, False)

    is option enabled



9
10
11
12
13
14
15
16
17
# File 'lib/ooxml_parser/common_parser/common_data/ooxml_document_object/ooxml_object_attribute_helper.rb', line 9

def option_enabled?(node, attribute_name = 'val')
  return true if node.attributes.empty?
  return true if node.to_s == '1'
  return false if node.to_s == '0'
  return false if node.attribute(attribute_name).nil?

  status = node.attribute(attribute_name).value
  !%w[false off 0].include?(status)
end