comparison modules/stdlib/lib/puppet/parser/functions/num2bool.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 adf6fe9bbc17
comparison
equal deleted inserted replaced
274:b2571c28fc27 275:d9352a684e62
1 # 1 #
2 # num2bool.rb 2 # num2bool.rb
3 # 3 #
4 module Puppet::Parser::Functions 4 module Puppet::Parser::Functions
5 newfunction(:num2bool, :type => :rvalue, :doc => <<-DOC 5 newfunction(:num2bool, :type => :rvalue, :doc => <<-DOC
6 This function converts a number or a string representation of a number into a 6 @summary
7 true boolean. Zero or anything non-numeric becomes false. Numbers higher then 0 7 This function converts a number or a string representation of a number into a
8 become true. 8 true boolean.
9
10 > *Note:* that since Puppet 5.0.0 the same can be achieved with the Puppet Type System.
11 See the new() function in Puppet for the many available type conversions.
12
13 @return [Boolean]
14 Boolean(0) # false for any zero or negative number
15 Boolean(1) # true for any positive number
9 DOC 16 DOC
10 ) do |arguments| 17 ) do |arguments|
11 18
12 raise(Puppet::ParseError, "num2bool(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size != 1 19 raise(Puppet::ParseError, "num2bool(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size != 1
13 20