5 module Puppet::Parser::Functions
6 newfunction(:swapcase, :type => :rvalue, :doc => <<-EOS
7 This function will swap the existing case of a string.
13 Would result in: "AbCd"
17 raise(Puppet::ParseError, "swapcase(): Wrong number of arguments " +
18 "given (#{arguments.size} for 1)") if arguments.size < 1
23 unless [Array, String].include?(klass)
24 raise(Puppet::ParseError, 'swapcase(): Requires either ' +
25 'array or string to work with')
29 # Numbers in Puppet are often string-encoded which is troublesome ...
30 result = value.collect { |i| i.is_a?(String) ? i.swapcase : i }
32 result = value.swapcase
39 # vim: set ts=2 sw=2 et :