Support for the XPath "mod" operator.

This commit is contained in:
Yorick Peterse committed 2014-08-29 09:31:11 +02:00
1 parent 78c8cd1323
commit 034b360d13
2 files changed
+50

No files matched your search

+16
View File
@@ -658,6 +658,22 @@ module Oga
return on_call_number(context, left) / on_call_number(context, right)
end
##
# Processes the `mod` operator.
#
# This operator converts the left and right expressions to numbers and
# returns the modulo of the two numbers.
#
# @param [Oga::XPath::Node] ast_node
# @param [Oga::XML::NodeSet] context
# @return [Float]
#
def on_mod(ast_node, context)
left, right = *ast_node
return on_call_number(context, left) % on_call_number(context, right)
end
##
# Delegates function calls to specific handlers.
#