puppetlabs-stdlib/flatten.rb
Krzysztof Wilczynski 872c7f3c42 Added body of the function flatten.
Signed-off-by: Krzysztof Wilczynski <krzysztof.wilczynski@linux.com>
2011-04-30 02:50:38 +01:00

25 lines
494 B
Ruby

#
# flatten.rb
#
module Puppet::Parser::Functions
newfunction(:flatten, :type => :rvalue, :doc => <<-EOS
EOS
) do |arguments|
raise(Puppet::ParseError, "flatten(): Wrong number of arguments " +
"given (#{arguments.size} for 1)") if arguments.size < 1
array = arguments[0]
unless array.is_a?(Array)
raise(Puppet::ParseError, 'flatten(): Requires array to work with')
end
result = array.flatten
return result
end
end
# vim: set ts=2 sw=2 et :