X-Git-Url: https://git.adam-barratt.org.uk/?p=mirror%2Fdsa-puppet.git;a=blobdiff_plain;f=3rdparty%2Fmodules%2Fstdlib%2Flib%2Fpuppet%2Fparser%2Ffunctions%2Fvalues_at.rb;h=337104207256a204a6534538ae577b2192f2f472;hp=cf53fa06016c62e8c5e35ac0a0b3064e6736337c;hb=30caaa85aed7015ca0d77216bff175eebd917eb7;hpb=6f656bd4265e3dab13b9af2bf96e9044322e9d8f diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/values_at.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/values_at.rb index cf53fa060..337104207 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/values_at.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/values_at.rb @@ -3,7 +3,8 @@ # module Puppet::Parser::Functions newfunction(:values_at, :type => :rvalue, :doc => <<-DOC - Finds value inside an array based on location. + @summary + 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: @@ -12,26 +13,28 @@ module Puppet::Parser::Functions * A range in the form of 'start-stop' (eg. 4-9) * An array combining the above - *Examples*: + @return + an array of values identified by location - values_at(['a','b','c'], 2) + @example **Usage** - Would return ['c']. + values_at(['a','b','c'], 2) + Would return ['c'] - values_at(['a','b','c'], ["0-1"]) + values_at(['a','b','c'], ["0-1"]) + Would return ['a','b'] - Would return ['a','b']. + values_at(['a','b','c','d','e'], [0, "2-3"]) + Would return ['a','c','d'] - values_at(['a','b','c','d','e'], [0, "2-3"]) - - Would return ['a','c','d']. - - Note that since Puppet 4.0.0 it is possible to slice an array with index and count directly in the language. + > *Note:* + Since Puppet 4.0.0 it is possible to slice an array with index and count directly in the language. A negative value is taken to be "from the end" of the array: - ['a', 'b', 'c', 'd'][1, 2] # results in ['b', 'c'] - ['a', 'b', 'c', 'd'][2, -1] # results in ['c', 'd'] - ['a', 'b', 'c', 'd'][1, -2] # results in ['b', 'c'] + `['a', 'b', 'c', 'd'][1, 2]` results in `['b', 'c']` + `['a', 'b', 'c', 'd'][2, -1]` results in `['c', 'd']` + `['a', 'b', 'c', 'd'][1, -2]` results in `['b', 'c']` + DOC ) do |arguments|