4 module Puppet::Parser::Functions
5 newfunction(:size, :type => :rvalue, :doc => <<-DOC
7 Returns the number of elements in a string, an array or a hash
10 the number of elements in a string, an array or a hash
12 > *Note:* that since Puppet 5.4.0, the length() function in Puppet is preferred over this. For versions
13 of Puppet < 5.4.0 use the stdlib length() function.
17 raise(Puppet::ParseError, "size(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty?
21 function_deprecation([:size, 'This method is going to be deprecated, please use the stdlib length function.'])
27 # Check whether your item is a numeric value or not ...
28 # This will take care about positive and/or negative numbers
29 # for both integer and floating-point values ...
31 # Please note that Puppet has no notion of hexadecimal
32 # nor octal numbers for its DSL at this point in time ...
36 raise(Puppet::ParseError, 'size(): Requires either string, array or hash to work with')
41 elsif item.is_a?(Array) || item.is_a?(Hash)
44 raise(Puppet::ParseError, 'size(): Unknown type given')
51 # vim: set ts=2 sw=2 et :