4 module Puppet::Parser::Functions
5 newfunction(:strip, :type => :rvalue, :doc => <<-DOC
6 This function removes leading and trailing whitespace from a string or from
7 every string inside an array.
13 Would result in: "aaa"
15 Note: from Puppet 6.0.0, the compatible function with the same name in Puppet core
16 will be used instead of this function.
20 raise(Puppet::ParseError, "strip(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.empty?
24 unless value.is_a?(Array) || value.is_a?(String)
25 raise(Puppet::ParseError, 'strip(): Requires either array or string to work with')
28 result = if value.is_a?(Array)
29 value.map { |i| i.is_a?(String) ? i.strip : i }
38 # vim: set ts=2 sw=2 et :