From 82eed89bccfe1af07caf925ce91e43b878bfda41 Mon Sep 17 00:00:00 2001 From: mh Date: Thu, 21 Oct 2010 00:40:23 +0200 Subject: add a function to do some array work --- lib/puppet/parser/functions/uniq_flatten.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 lib/puppet/parser/functions/uniq_flatten.rb (limited to 'lib') diff --git a/lib/puppet/parser/functions/uniq_flatten.rb b/lib/puppet/parser/functions/uniq_flatten.rb new file mode 100644 index 0000000..a4cae40 --- /dev/null +++ b/lib/puppet/parser/functions/uniq_flatten.rb @@ -0,0 +1,10 @@ +Puppet::Parser::Functions::newfunction( + :uniq_flatten, + :type => :rvalue, + :doc => "Flattens an array and make it uniq + + Example: uniq_flatten([['a','b'],'a']) -> ['a','b']" +) do |args| + raise Puppet::ParseError, 'uniq_flatten() needs one arguments' if args.length != 1 + args[0].to_a.flatten.uniq +end -- cgit v1.2.3