5 module Puppet::Parser::Functions
6 newfunction(:chomp, :type => :rvalue, :doc => <<-'EOS'
7 Removes the record separator from the end of a string or an array of
8 strings, for example `hello\n` becomes `hello`.
9 Requires a single string or array as an input.
13 raise(Puppet::ParseError, "chomp(): Wrong number of arguments " +
14 "given (#{arguments.size} for 1)") if arguments.size < 1
18 unless value.is_a?(Array) || value.is_a?(String)
19 raise(Puppet::ParseError, 'chomp(): Requires either ' +
20 'array or string to work with')
24 # Numbers in Puppet are often string-encoded which is troublesome ...
25 result = value.collect { |i| i.is_a?(String) ? i.chomp : i }
34 # vim: set ts=2 sw=2 et :