Class: Matchers::XML::DocumentContainsXPath
- Inherits:
-
Object
- Object
- Matchers::XML::DocumentContainsXPath
- Defined in:
- lib/matchers/xml/document_contains_xpath.rb
Instance Method Summary collapse
-
#initialize(xpath_expr_s, occurrences = 1) ⇒ DocumentContainsXPath
constructor
A new instance of DocumentContainsXPath.
- #matches?(document_s) ⇒ Boolean
Constructor Details
#initialize(xpath_expr_s, occurrences = 1) ⇒ DocumentContainsXPath
Returns a new instance of DocumentContainsXPath.
22 23 24 25 |
# File 'lib/matchers/xml/document_contains_xpath.rb', line 22 def initialize(xpath_expr_s, occurrences = 1) @xpath_expr_s = xpath_expr_s @occurrences = occurrences end |
Instance Method Details
#matches?(document_s) ⇒ Boolean
28 29 30 31 32 |
# File 'lib/matchers/xml/document_contains_xpath.rb', line 28 def matches?(document_s) xml_doc = REXML::Document.new(document_s) nodes = REXML::XPath.match(xml_doc, @xpath_expr_s) nodes.count >= @occurrences end |