]> git.donarmstrong.com Git - dsa-puppet.git/blob - modules/stdlib/lib/puppet/parser/functions/delete.rb
upgrade to concat 2.0.0
[dsa-puppet.git] / modules / stdlib / lib / puppet / parser / functions / delete.rb
1 #
2 # delete.rb
3 #
4
5 # TODO(Krzysztof Wilczynski): We need to add support for regular expression ...
6 # TODO(Krzysztof Wilczynski): Support for strings and hashes too ...
7
8 module Puppet::Parser::Functions
9   newfunction(:delete, :type => :rvalue, :doc => <<-EOS
10 Deletes a selected element from an array.
11
12 *Examples:*
13
14     delete(['a','b','c'], 'b')
15
16 Would return: ['a','c']
17     EOS
18   ) do |arguments|
19
20     if (arguments.size != 2) then
21       raise(Puppet::ParseError, "delete(): Wrong number of arguments "+
22         "given #{arguments.size} for 2")
23     end
24
25     a = arguments[0]
26     item = arguments[1]
27
28     a.delete(item)
29     a
30
31   end
32 end
33
34 # vim: set ts=2 sw=2 et :