5 module Puppet::Parser::Functions
6 newfunction(:join, :type => :rvalue, :doc => <<-EOS
7 This function joins an array into a string using a seperator.
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 " +
19 "given (#{arguments.size} for 1)") if arguments.size < 1
23 unless array.is_a?(Array)
24 raise(Puppet::ParseError, 'join(): Requires array to work with')
27 suffix = arguments[1] if arguments[1]
30 unless suffix.is_a?(String)
31 raise(Puppet::ParseError, 'join(): Requires string to work with')
35 result = suffix ? array.join(suffix) : array.join
41 # vim: set ts=2 sw=2 et :