#
# round.rb
#
-
module Puppet::Parser::Functions
- newfunction(:round, :type => :rvalue, :doc => <<-EOS
- Rounds a number to the nearest integer
-
- *Examples:*
+ newfunction(:round, :type => :rvalue, :doc => <<-DOC
+ @summary
+ Rounds a number to the nearest integer
- round(2.9)
+ @return
+ the rounded value as integer
- returns: 3
+ @example
- round(2.4)
+ ```round(2.9)``` returns ```3```
- returns: 2
+ ```round(2.4)``` returns ```2```
- EOS
- ) do |args|
+ > *Note:* from Puppet 6.0.0, the compatible function with the same name in Puppet core
+ will be used instead of this function.
+ DOC
+ ) do |args|
raise Puppet::ParseError, "round(): Wrong number of arguments given #{args.size} for 1" if args.size != 1
raise Puppet::ParseError, "round(): Expected a Numeric, got #{args[0].class}" unless args[0].is_a? Numeric