From 99a93d366f2e1efb977fcc8fe300d3d8357c8214 Mon Sep 17 00:00:00 2001 From: Ken Barber Date: Fri, 29 Apr 2011 09:27:10 +0200 Subject: Convert to module format. --- lib/puppet/parser/functions/values.rb | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 lib/puppet/parser/functions/values.rb (limited to 'lib/puppet/parser/functions/values.rb') diff --git a/lib/puppet/parser/functions/values.rb b/lib/puppet/parser/functions/values.rb new file mode 100644 index 0000000..c1c4a77 --- /dev/null +++ b/lib/puppet/parser/functions/values.rb @@ -0,0 +1,25 @@ +# +# values.rb +# + +module Puppet::Parser::Functions + newfunction(:values, :type => :rvalue, :doc => <<-EOS + EOS + ) do |arguments| + + raise(Puppet::ParseError, "values(): Wrong number of arguments " + + "given (#{arguments.size} for 1)") if arguments.size < 1 + + hash = arguments[0] + + unless hash.is_a?(Hash) + raise(Puppet::ParseError, 'values(): Requires hash to work with') + end + + result = hash.values + + return result + end +end + +# vim: set ts=2 sw=2 et : -- cgit v1.2.3 From 19313b43ea04066a88a0b78e83650ac52785e2e9 Mon Sep 17 00:00:00 2001 From: Ken Barber Date: Fri, 29 Jul 2011 22:18:56 +0100 Subject: (#3) Apply missing documentation to more functions. --- lib/puppet/parser/functions/values.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'lib/puppet/parser/functions/values.rb') diff --git a/lib/puppet/parser/functions/values.rb b/lib/puppet/parser/functions/values.rb index c1c4a77..1606756 100644 --- a/lib/puppet/parser/functions/values.rb +++ b/lib/puppet/parser/functions/values.rb @@ -4,6 +4,20 @@ module Puppet::Parser::Functions newfunction(:values, :type => :rvalue, :doc => <<-EOS +When given a hash this function will return the values of that hash. + +*Examples:* + + $hash = { + 'a' => 1, + 'b' => 2, + 'c' => 3, + } + values($hash) + +This example would return: + + [1,2,3] EOS ) do |arguments| -- cgit v1.2.3