Class: DocTemplate::XpathFunctions
- Inherits:
-
Object
- Object
- DocTemplate::XpathFunctions
- Defined in:
- lib/doc_template/xpath_functions.rb
Instance Method Summary collapse
- #case_insensitive_contains(node_set, str_to_match) ⇒ Object
- #case_insensitive_equals(node_set, str_to_match) ⇒ Object
- #case_regular(node_set, re_to_match) ⇒ Object
Instance Method Details
#case_insensitive_contains(node_set, str_to_match) ⇒ Object
11 12 13 |
# File 'lib/doc_template/xpath_functions.rb', line 11 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 |
#case_insensitive_equals(node_set, str_to_match) ⇒ Object
5 6 7 8 9 |
# File 'lib/doc_template/xpath_functions.rb', line 5 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 |
#case_regular(node_set, re_to_match) ⇒ Object
15 16 17 |
# File 'lib/doc_template/xpath_functions.rb', line 15 def case_regular(node_set, re_to_match) node_set.to_s.match?(Regexp.new(re_to_match, true)) ? node_set : [] end |