5 module Puppet::Parser::Functions
6 newfunction(:clamp, :type => :rvalue, :arity => -2, :doc => <<-EOS
7 Clamps value to a range.
13 raise(Puppet::ParseError, 'clamp(): Wrong number of arguments, need three to clamp') if args.size != 3
19 raise(Puppet::ParseError, "clamp(): Required explicit numeric (#{value}:String)") unless value =~ /^\d+$/
21 raise(Puppet::ParseError, "clamp(): The Hash type is not allowed (#{value})")
25 # convert to numeric each element
26 # then sort them and get a middle value
27 args.map{ |n| n.to_i }.sort[1]