Update stdlib and concat to 6.1.0 both
[mirror/dsa-puppet.git] / 3rdparty / modules / stdlib / lib / puppet / parser / functions / size.rb
index b503aa0..39b856c 100644 (file)
@@ -1,14 +1,20 @@
 #
 # size.rb
 #
-
 module Puppet::Parser::Functions
-  newfunction(:size, :type => :rvalue, :doc => <<-EOS
-Returns the number of elements in a string, an array or a hash
-    EOS
-  ) do |arguments|
+  newfunction(:size, :type => :rvalue, :doc => <<-DOC
+    @summary
+      Returns the number of elements in a string, an array or a hash
+
+    @return
+      the number of elements in a string, an array or a hash
 
-    raise(Puppet::ParseError, "size(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size < 1
+    > *Note:* that since Puppet 5.4.0, the length() function in Puppet is preferred over this. For versions
+    of Puppet < 5.4.0 use the stdlib length() function.
+  DOC
+             ) do |arguments|
+
+    raise(Puppet::ParseError, "size(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty?
 
     item = arguments[0]
 
@@ -28,7 +34,6 @@ Returns the number of elements in a string, an array or a hash
         Float(item)
 
         raise(Puppet::ParseError, 'size(): Requires either string, array or hash to work with')
-
       rescue ArgumentError
         result = item.size
       end