2011-04-30 04:16:12 +02:00
|
|
|
#
|
|
|
|
# delete.rb
|
|
|
|
#
|
|
|
|
|
|
|
|
# TODO(Krzysztof Wilczynski): We need to add support for regular expression ...
|
|
|
|
# TODO(Krzysztof Wilczynski): Support for strings and hashes too ...
|
|
|
|
|
|
|
|
module Puppet::Parser::Functions
|
|
|
|
newfunction(:delete, :type => :rvalue, :doc => <<-EOS
|
2011-07-30 00:09:30 +02:00
|
|
|
Deletes a selected element from an array.
|
|
|
|
|
|
|
|
*Examples:*
|
|
|
|
|
|
|
|
delete(['a','b','c'], 'b')
|
|
|
|
|
|
|
|
Would return: ['a','c']
|
2011-04-30 04:16:12 +02:00
|
|
|
EOS
|
|
|
|
) do |arguments|
|
2011-06-29 22:21:55 +02:00
|
|
|
|
|
|
|
if (arguments.size != 2) then
|
2011-07-30 00:09:30 +02:00
|
|
|
raise(Puppet::ParseError, "delete(): Wrong number of arguments "+
|
2011-06-29 22:21:55 +02:00
|
|
|
"given #{arguments.size} for 2")
|
|
|
|
end
|
|
|
|
|
2011-06-30 00:37:37 +02:00
|
|
|
a = arguments[0]
|
|
|
|
item = arguments[1]
|
|
|
|
|
|
|
|
a.delete(item)
|
|
|
|
a
|
|
|
|
|
2011-04-30 04:16:12 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# vim: set ts=2 sw=2 et :
|