Sha256: d4c8ece08195ad86f07c0d4b3b510782ea1b44271d7c71b1e1cedfc9f72f947c

Contents?: true

Size: 1.07 KB

Versions: 49

Compression:

Stored size: 1.07 KB

Contents

# frozen_string_literal: true

module OoxmlParser
  # Module for stroing some attribute helpers for objects
  module OoxmlObjectAttributeHelper
    # @param node [Nokogiri::XML:Element] node to parse
    # @param attribute_name [String] name of attribute
    # @return [True, False] is option enabled
    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

    # @param node [Nokogiri::XML:Element] node to parse
    # @param attribute_name [String] name of attribute
    # @return [True, False] is attribute enabled
    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
  end
end

Version data entries

49 entries across 49 versions & 1 rubygems

Version Path
ooxml_parser-0.38.0 lib/ooxml_parser/common_parser/common_data/ooxml_document_object/ooxml_object_attribute_helper.rb
ooxml_parser-0.37.1 lib/ooxml_parser/common_parser/common_data/ooxml_document_object/ooxml_object_attribute_helper.rb
ooxml_parser-0.37.0 lib/ooxml_parser/common_parser/common_data/ooxml_document_object/ooxml_object_attribute_helper.rb
ooxml_parser-0.36.1 lib/ooxml_parser/common_parser/common_data/ooxml_document_object/ooxml_object_attribute_helper.rb
ooxml_parser-0.36.0 lib/ooxml_parser/common_parser/common_data/ooxml_document_object/ooxml_object_attribute_helper.rb
ooxml_parser-0.35.0 lib/ooxml_parser/common_parser/common_data/ooxml_document_object/ooxml_object_attribute_helper.rb
ooxml_parser-0.34.2 lib/ooxml_parser/common_parser/common_data/ooxml_document_object/ooxml_object_attribute_helper.rb
ooxml_parser-0.34.1 lib/ooxml_parser/common_parser/common_data/ooxml_document_object/ooxml_object_attribute_helper.rb
ooxml_parser-0.34.0 lib/ooxml_parser/common_parser/common_data/ooxml_document_object/ooxml_object_attribute_helper.rb
ooxml_parser-0.33.0 lib/ooxml_parser/common_parser/common_data/ooxml_document_object/ooxml_object_attribute_helper.rb
ooxml_parser-0.32.0 lib/ooxml_parser/common_parser/common_data/ooxml_document_object/ooxml_object_attribute_helper.rb
ooxml_parser-0.31.0 lib/ooxml_parser/common_parser/common_data/ooxml_document_object/ooxml_object_attribute_helper.rb
ooxml_parser-0.30.0 lib/ooxml_parser/common_parser/common_data/ooxml_document_object/ooxml_object_attribute_helper.rb
ooxml_parser-0.29.0 lib/ooxml_parser/common_parser/common_data/ooxml_document_object/ooxml_object_attribute_helper.rb
ooxml_parser-0.28.0 lib/ooxml_parser/common_parser/common_data/ooxml_document_object/ooxml_object_attribute_helper.rb
ooxml_parser-0.27.0 lib/ooxml_parser/common_parser/common_data/ooxml_document_object/ooxml_object_attribute_helper.rb
ooxml_parser-0.26.0 lib/ooxml_parser/common_parser/common_data/ooxml_document_object/ooxml_object_attribute_helper.rb
ooxml_parser-0.25.0 lib/ooxml_parser/common_parser/common_data/ooxml_document_object/ooxml_object_attribute_helper.rb
ooxml_parser-0.24.0 lib/ooxml_parser/common_parser/common_data/ooxml_document_object/ooxml_object_attribute_helper.rb
ooxml_parser-0.23.0 lib/ooxml_parser/common_parser/common_data/ooxml_document_object/ooxml_object_attribute_helper.rb