summaryrefslogtreecommitdiff
path: root/lib/puppet/parser/functions/values_at.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/puppet/parser/functions/values_at.rb')
-rw-r--r--lib/puppet/parser/functions/values_at.rb18
1 files changed, 6 insertions, 12 deletions
diff --git a/lib/puppet/parser/functions/values_at.rb b/lib/puppet/parser/functions/values_at.rb
index f350f53..04a3d1a 100644
--- a/lib/puppet/parser/functions/values_at.rb
+++ b/lib/puppet/parser/functions/values_at.rb
@@ -29,8 +29,7 @@ Would return ['a','c','d'].
EOS
) do |arguments|
- raise(Puppet::ParseError, "values_at(): Wrong number of " +
- "arguments given (#{arguments.size} for 2)") if arguments.size < 2
+ raise(Puppet::ParseError, "values_at(): Wrong number of arguments given (#{arguments.size} for 2)") if arguments.size < 2
array = arguments.shift
@@ -41,8 +40,7 @@ Would return ['a','c','d'].
indices = [arguments.shift].flatten() # Get them all ... Pokemon ...
if not indices or indices.empty?
- raise(Puppet::ParseError, 'values_at(): You must provide ' +
- 'at least one positive index to collect')
+ raise(Puppet::ParseError, 'values_at(): You must provide at least one positive index to collect')
end
result = []
@@ -57,11 +55,9 @@ Would return ['a','c','d'].
type = m[2]
if start > stop
- raise(Puppet::ParseError, 'values_at(): Stop index in ' +
- 'given indices range is smaller than the start index')
+ raise(Puppet::ParseError, 'values_at(): Stop index in given indices range is smaller than the start index')
elsif stop > array.size - 1 # First element is at index 0 is it not?
- raise(Puppet::ParseError, 'values_at(): Stop index in ' +
- 'given indices range exceeds array size')
+ raise(Puppet::ParseError, 'values_at(): Stop index in given indices range exceeds array size')
end
range = case type
@@ -73,16 +69,14 @@ Would return ['a','c','d'].
else
# Only positive numbers allowed in this case ...
if not i.match(/^\d+$/)
- raise(Puppet::ParseError, 'values_at(): Unknown format ' +
- 'of given index')
+ raise(Puppet::ParseError, 'values_at(): Unknown format of given index')
end
# In Puppet numbers are often string-encoded ...
i = i.to_i
if i > array.size - 1 # Same story. First element is at index 0 ...
- raise(Puppet::ParseError, 'values_at(): Given index ' +
- 'exceeds array size')
+ raise(Puppet::ParseError, 'values_at(): Given index exceeds array size')
end
indices_list << i