Support for the XPath round() function.

This commit is contained in:
Yorick Peterse committed 2014-08-28 00:00:25 +02:00
1 parent a2b8e3c954
commit 543112dcdc
2 files changed
+46

No files matched your search

+16
View File
@@ -1216,6 +1216,22 @@ module Oga
return number.nan? ? number : number.ceil.to_f
end
##
# Processes the `round()` function call.
#
# This function call rounds the 1st argument to the closest integer number
# and then returns that number as a float.
#
# @param [Oga::XML::NodeSet] context
# @param [Oga::XPath::Node] expression
# @return [Float]
#
def on_call_round(context, expression)
number = on_call_number(context, expression)
return number.nan? ? number : number.round.to_f
end
##
# Processes an `(int)` node.
#