oga/spec/support/evaluation_helpers.rb

26 lines
616 B
Ruby
Raw Normal View History

2014-11-04 22:33:42 +00:00
module Oga
module EvaluationHelpers
##
# @param [Oga::XML::Document] document
# @param [String] xpath
# @return [Oga::XML::NodeSet]
#
def evaluate_xpath(document, xpath)
return Oga::XPath::Evaluator.new(document).evaluate(xpath)
end
2014-11-04 22:33:42 +00:00
##
# Parses and evaluates a CSS expression.
#
# @param [Oga::XML::Document] document
# @param [String] css
# @return [Oga::XML::NodeSet]
#
def evaluate_css(document, css)
xpath = parse_css(css)
return Oga::XPath::Evaluator.new(document).evaluate_ast(xpath)
end
end # EvaluationHelpers
end # Oga