source: other-projects/hathitrust/vagrant-hadoop-cluster/trunk/modules/stdlib/lib/puppet/parser/functions/values.rb@ 30903

Last change on this file since 30903 was 30903, checked in by davidb, 8 years ago

Vagrant provisioning files for a 4-node Hadoop cluster. See README.txt for more details

File size: 694 bytes
Line 
1#
2# values.rb
3#
4
5module Puppet::Parser::Functions
6 newfunction(:values, :type => :rvalue, :doc => <<-EOS
7When given a hash this function will return the values of that hash.
8
9*Examples:*
10
11 $hash = {
12 'a' => 1,
13 'b' => 2,
14 'c' => 3,
15 }
16 values($hash)
17
18This example would return:
19
20 [1,2,3]
21 EOS
22 ) do |arguments|
23
24 raise(Puppet::ParseError, "values(): Wrong number of arguments " +
25 "given (#{arguments.size} for 1)") if arguments.size < 1
26
27 hash = arguments[0]
28
29 unless hash.is_a?(Hash)
30 raise(Puppet::ParseError, 'values(): Requires hash to work with')
31 end
32
33 result = hash.values
34
35 return result
36 end
37end
38
39# vim: set ts=2 sw=2 et :
Note: See TracBrowser for help on using the repository browser.