Sha256: 5ee5ffc2ce0ab25458c047014f0a274c37b18ad2c4af69c7cef7685aca33b285
Contents?: true
Size: 630 Bytes
Versions: 43
Compression:
Stored size: 630 Bytes
Contents
module Puppet::Parser::Functions newfunction(:min, :type => :rvalue, :doc => <<-EOS Returns the lowest value of all arguments. Requires at least one argument. EOS ) do |args| raise(Puppet::ParseError, "min(): Wrong number of arguments " + "need at least one") if args.size == 0 # Sometimes we get numbers as numerics and sometimes as strings. # We try to compare them as numbers when possible return args.min do |a,b| if a.to_s =~ /\A^-?\d+(.\d+)?\z/ and b.to_s =~ /\A-?\d+(.\d+)?\z/ then a.to_f <=> b.to_f else a.to_s <=> b.to_s end end end end
Version data entries
43 entries across 43 versions & 4 rubygems