summaryrefslogtreecommitdiff
path: root/lib/puppet/parser/functions/values_at.rb
diff options
context:
space:
mode:
authorKen Barber <ken@bob.sh>2011-07-29 22:18:56 +0100
committerKen Barber <ken@bob.sh>2011-07-29 22:18:56 +0100
commit19313b43ea04066a88a0b78e83650ac52785e2e9 (patch)
tree15c8e5de95a4ffa297683a1bdab0d45a1bfb97eb /lib/puppet/parser/functions/values_at.rb
parentf9634b7f9b03be86e25dc740cdcda754a0d2bf7d (diff)
(#3) Apply missing documentation to more functions.
Diffstat (limited to 'lib/puppet/parser/functions/values_at.rb')
-rw-r--r--lib/puppet/parser/functions/values_at.rb25
1 files changed, 22 insertions, 3 deletions
diff --git a/lib/puppet/parser/functions/values_at.rb b/lib/puppet/parser/functions/values_at.rb
index 331af6a..7f1de8e 100644
--- a/lib/puppet/parser/functions/values_at.rb
+++ b/lib/puppet/parser/functions/values_at.rb
@@ -2,11 +2,30 @@
# values_at.rb
#
-# TODO(Krzysztof Wilczynski): Support for hashes would be nice too ...
-# TODO(Krzysztof Wilczynski): We probably need to approach numeric values differently ...
-
module Puppet::Parser::Functions
newfunction(:values_at, :type => :rvalue, :doc => <<-EOS
+Finds value inside an array based on location.
+
+The first argument is the array you want to analyze, and the second element can
+be a combination of:
+
+* A single numeric index
+* A range in the form of 'start-stop' (eg. 4-9)
+* An array combining the above
+
+*Examples*:
+
+ values_at(['a','b','c'], 2)
+
+Would return ['c'].
+
+ values_at(['a','b','c'], ["0-1"])
+
+Would return ['a','b'].
+
+ values_at(['a','b','c','d','e'], [0, "2-3"])
+
+Would return ['a','c','d'].
EOS
) do |arguments|