5 module Puppet::Parser::Functions
6 newfunction(:hash, :type => :rvalue, :doc => <<-EOS
7 This function converts and array into a hash.
11 hash(['a',1,'b',2,'c',3])
13 Would return: {'a'=>1,'b'=>2,'c'=>3}
17 raise(Puppet::ParseError, "hash(): Wrong number of arguments " +
18 "given (#{arguments.size} for 1)") if arguments.size < 1
22 unless array.is_a?(Array)
23 raise(Puppet::ParseError, 'hash(): Requires array to work with')
29 # This is to make it compatible with older version of Ruby ...
33 raise(Puppet::ParseError, 'hash(): Unable to compute ' +
34 'hash from array given')
41 # vim: set ts=2 sw=2 et :