Sha256: 6a55e2e67d7858ffac44a90a6ed5d5ce5ee7a455637dbb7dfff9dd63772ae0f6

Contents?: true

Size: 601 Bytes

Versions: 13

Compression:

Stored size: 601 Bytes

Contents

# frozen_string_literal: true

module DocTemplate
  class XpathFunctions
    def case_insensitive_equals(node_set, str_to_match)
      return node_set.to_s.squish.casecmp(str_to_match).zero? if node_set.is_a?(String)

      node_set.find_all { |node| node.to_s.squish.casecmp(str_to_match).zero? }
    end

    def case_insensitive_contains(node_set, str_to_match)
      node_set.find_all { |node| node.to_s.downcase.include?(str_to_match.to_s.downcase) }
    end

    def case_regular(node_set, re_to_match)
      node_set.to_s.match?(Regexp.new(re_to_match, true)) ? node_set : []
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
lcms-engine-0.5.5 lib/doc_template/xpath_functions.rb
lcms-engine-0.5.4 lib/doc_template/xpath_functions.rb
lcms-engine-0.5.3 lib/doc_template/xpath_functions.rb
lcms-engine-0.5.2 lib/doc_template/xpath_functions.rb
lcms-engine-0.5.1 lib/doc_template/xpath_functions.rb
lcms-engine-0.5.0 lib/doc_template/xpath_functions.rb
lcms-engine-0.4.2 lib/doc_template/xpath_functions.rb
lcms-engine-0.4.1 lib/doc_template/xpath_functions.rb
lcms-engine-0.4.0 lib/doc_template/xpath_functions.rb
lcms-engine-0.3.1 lib/doc_template/xpath_functions.rb
lcms-engine-0.1.4 lib/doc_template/xpath_functions.rb
lcms-engine-0.3.0 lib/doc_template/xpath_functions.rb
lcms-engine-0.1.3 lib/doc_template/xpath_functions.rb