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
19 unless [Array, String].include?(klass)
20 raise(Puppet::ParseError, 'chomp(): Requires either ' +
21 'array or string to work with')
25 # Numbers in Puppet are often string-encoded which is troublesome ...
26 result = value.collect { |i| i.is_a?(String) ? i.chomp : i }
35 # vim: set ts=2 sw=2 et :