X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=3rdparty%2Fmodules%2Fstdlib%2Flib%2Fpuppet%2Fparser%2Ffunctions%2Fnum2bool.rb;h=6e530db9ae9522201759ec935313d1138c2e4388;hb=30caaa85aed7015ca0d77216bff175eebd917eb7;hp=af0e6ed7895109392812d14f13725a6f27fc2e67;hpb=ad88f67c13ae0f1a08936dad643f1e3509ab5f40;p=mirror%2Fdsa-puppet.git diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/num2bool.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/num2bool.rb index af0e6ed78..6e530db9a 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/num2bool.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/num2bool.rb @@ -1,22 +1,27 @@ # # num2bool.rb # - module Puppet::Parser::Functions - newfunction(:num2bool, :type => :rvalue, :doc => <<-EOS -This function converts a number or a string representation of a number into a -true boolean. Zero or anything non-numeric becomes false. Numbers higher then 0 -become true. - EOS - ) do |arguments| + newfunction(:num2bool, :type => :rvalue, :doc => <<-DOC + @summary + This function converts a number or a string representation of a number into a + true boolean. + + > *Note:* that since Puppet 5.0.0 the same can be achieved with the Puppet Type System. + See the new() function in Puppet for the many available type conversions. + + @return [Boolean] + Boolean(0) # false for any zero or negative number + Boolean(1) # true for any positive number + DOC + ) do |arguments| - raise(Puppet::ParseError, "num2bool(): Wrong number of arguments " + - "given (#{arguments.size} for 1)") if arguments.size != 1 + raise(Puppet::ParseError, "num2bool(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size != 1 number = arguments[0] case number - when Numeric + when Numeric # rubocop:disable Lint/EmptyWhen : Required for the module to work # Yay, it's a number when String begin