Class: AbideDevUtils::XCCDF::Parser::Helpers::XPath::FindElement
- Inherits:
-
Object
- Object
- AbideDevUtils::XCCDF::Parser::Helpers::XPath::FindElement
- Defined in:
- lib/abide_dev_utils/xccdf/parser/helpers.rb
Overview
Implements class methods to help with finding elements via XPath
Class Method Summary collapse
- .at_xpath(element, path) ⇒ Object
- .named_at_xpath(element, path) ⇒ Object
- .named_xpath(element, path) ⇒ Object
- .namespace_safe_at_xpath(element, path) ⇒ Object
- .namespace_safe_xpath(element, path) ⇒ Object
- .xpath(element, path) ⇒ Object
Class Method Details
.at_xpath(element, path) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/abide_dev_utils/xccdf/parser/helpers.rb', line 22 def self.at_xpath(element, path) elem = namespace_safe_at_xpath(element, path) return named_at_xpath(element, path) if elem.nil? elem end |
.named_at_xpath(element, path) ⇒ Object
45 46 47 |
# File 'lib/abide_dev_utils/xccdf/parser/helpers.rb', line 45 def self.named_at_xpath(element, path) element.at_xpath("*[name()='#{path}']") end |
.named_xpath(element, path) ⇒ Object
41 42 43 |
# File 'lib/abide_dev_utils/xccdf/parser/helpers.rb', line 41 def self.named_xpath(element, path) element.xpath("*[name()='#{path}']") end |
.namespace_safe_at_xpath(element, path) ⇒ Object
35 36 37 38 39 |
# File 'lib/abide_dev_utils/xccdf/parser/helpers.rb', line 35 def self.namespace_safe_at_xpath(element, path) element.at_xpath(path) rescue Nokogiri::XML::XPath::SyntaxError named_at_xpath(element, path) end |
.namespace_safe_xpath(element, path) ⇒ Object
29 30 31 32 33 |
# File 'lib/abide_dev_utils/xccdf/parser/helpers.rb', line 29 def self.namespace_safe_xpath(element, path) element.xpath(path) rescue Nokogiri::XML::XPath::SyntaxError named_xpath(element, path) end |
.xpath(element, path) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/abide_dev_utils/xccdf/parser/helpers.rb', line 15 def self.xpath(element, path) elem = namespace_safe_xpath(element, path) return named_xpath(element, path) if elem.nil? elem end |