comparison modules/stdlib/lib/puppet/parser/functions/round.rb @ 275:d9352a684e62

Mass update of modules to remove deprecation warnings
author IBBoard <dev@ibboard.co.uk>
date Sun, 26 Jan 2020 11:36:07 +0000
parents c42fb28cff86
children
comparison
equal deleted inserted replaced
274:b2571c28fc27 275:d9352a684e62
1 # 1 #
2 # round.rb 2 # round.rb
3 # 3 #
4 module Puppet::Parser::Functions 4 module Puppet::Parser::Functions
5 newfunction(:round, :type => :rvalue, :doc => <<-DOC 5 newfunction(:round, :type => :rvalue, :doc => <<-DOC
6 Rounds a number to the nearest integer 6 @summary
7 Rounds a number to the nearest integer
7 8
8 *Examples:* 9 @return
10 the rounded value as integer
9 11
10 round(2.9) 12 @example
11 13
12 returns: 3 14 ```round(2.9)``` returns ```3```
13 15
14 round(2.4) 16 ```round(2.4)``` returns ```2```
15 17
16 returns: 2 18 > *Note:* from Puppet 6.0.0, the compatible function with the same name in Puppet core
17 19 will be used instead of this function.
18 DOC 20 DOC
19 ) do |args| 21 ) do |args|
20 22
21 raise Puppet::ParseError, "round(): Wrong number of arguments given #{args.size} for 1" if args.size != 1 23 raise Puppet::ParseError, "round(): Wrong number of arguments given #{args.size} for 1" if args.size != 1
22 raise Puppet::ParseError, "round(): Expected a Numeric, got #{args[0].class}" unless args[0].is_a? Numeric 24 raise Puppet::ParseError, "round(): Expected a Numeric, got #{args[0].class}" unless args[0].is_a? Numeric