5 module Puppet::Parser::Functions
6 newfunction(:join, :type => :rvalue, :doc => <<-EOS
7 This function joins an array into a string using a separator.
11 join(['a','b','c'], ",")
13 Would result in: "a,b,c"
17 # Technically we support two arguments but only first is mandatory ...
18 raise(Puppet::ParseError, "join(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size < 1
22 unless array.is_a?(Array)
23 raise(Puppet::ParseError, 'join(): Requires array to work with')
26 suffix = arguments[1] if arguments[1]
29 unless suffix.is_a?(String)
30 raise(Puppet::ParseError, 'join(): Requires string to work with')
34 result = suffix ? array.join(suffix) : array.join
40 # vim: set ts=2 sw=2 et :