5 module Puppet::Parser::Functions
6 newfunction(:upcase, :type => :rvalue, :doc => <<-EOS
7 Converts a string or an array of strings to uppercase.
19 raise(Puppet::ParseError, "upcase(): Wrong number of arguments " +
20 "given (#{arguments.size} for 1)") if arguments.size != 1
24 unless value.is_a?(Array) || value.is_a?(Hash) || value.respond_to?(:upcase)
25 raise(Puppet::ParseError, 'upcase(): Requires an ' +
26 'array, hash or object that responds to upcase in order to work')
30 # Numbers in Puppet are often string-encoded which is troublesome ...
31 result = value.collect { |i| function_upcase([i]) }
32 elsif value.is_a?(Hash)
34 value.each_pair do |k, v|
35 result[function_upcase([k])] = function_upcase([v])
45 # vim: set ts=2 sw=2 et :