summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKrzysztof Wilczynski <krzysztof.wilczynski@linux.com>2011-04-30 00:57:24 +0100
committerKrzysztof Wilczynski <krzysztof.wilczynski@linux.com>2011-04-30 00:57:24 +0100
commit555c50d73595478a8a422b83d073514f7dbed0f0 (patch)
tree66311d0bca7406d403f1ee7a0baaffd3b61e66c3
parent0fabca9a6536dc82cea80a6fca996b8028450cb4 (diff)
Moved to unless from if not for code clarity and changed wording
of few error messages. Signed-off-by: Krzysztof Wilczynski <krzysztof.wilczynski@linux.com>
-rw-r--r--delete_at.rb10
1 files changed, 5 insertions, 5 deletions
diff --git a/delete_at.rb b/delete_at.rb
index 1869476..10190ba 100644
--- a/delete_at.rb
+++ b/delete_at.rb
@@ -12,25 +12,25 @@ module Puppet::Parser::Functions
array = arguments[0]
- if not array.is_a?(Array)
- raise(Puppet::ParseError, 'delete_at(): Requires an array to work with')
+ unless array.is_a?(Array)
+ raise(Puppet::ParseError, 'delete_at(): Requires array to work with')
end
index = arguments[1]
if index.is_a?(String) and not index.match(/^\d+$/)
raise(Puppet::ParseError, 'delete_at(): You must provide ' +
- 'positive numeric index')
+ 'non-negative numeric index')
end
result = array.clone
- # In Puppet numbers are often string-encoded ...
+ # Numbers in Puppet are often string-encoded which is troublesome ...
index = index.to_i
if index > result.size - 1 # First element is at index 0 is it not?
raise(Puppet::ParseError, 'delete_at(): Given index ' +
- 'exceeds array size')
+ 'exceeds size of array given')
end
result.delete_at(index) # We ignore the element that got deleted ...