4 module Puppet::Parser::Functions
5 newfunction(:min, :type => :rvalue, :doc => <<-DOC
6 Returns the lowest value of all arguments.
7 Requires at least one argument.
9 Note: from Puppet 6.0.0, the compatible function with the same name in Puppet core
10 will be used instead of this function.
14 raise(Puppet::ParseError, 'min(): Wrong number of arguments need at least one') if args.empty?
16 # Sometimes we get numbers as numerics and sometimes as strings.
17 # We try to compare them as numbers when possible
18 return args.min do |a, b|
19 if a.to_s =~ %r{\A^-?\d+(.\d+)?\z} && b.to_s =~ %r{\A-?\d+(.\d+)?\z}