5 module Puppet::Parser::Functions
6 newfunction(:capitalize, :type => :rvalue, :doc => <<-EOS
7 Capitalizes the first letter of a string or array of strings.
8 Requires either a single string or an array as an input.
12 raise(Puppet::ParseError, "capitalize(): Wrong number of arguments " +
13 "given (#{arguments.size} for 1)") if arguments.size < 1
18 unless [Array, String].include?(klass)
19 raise(Puppet::ParseError, 'capitalize(): Requires either ' +
20 'array or string to work with')
24 # Numbers in Puppet are often string-encoded which is troublesome ...
25 result = value.collect { |i| i.is_a?(String) ? i.capitalize : i }
27 result = value.capitalize
34 # vim: set ts=2 sw=2 et :