summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKrzysztof Wilczynski <krzysztof.wilczynski@linux.com>2011-04-30 02:46:03 +0100
committerKrzysztof Wilczynski <krzysztof.wilczynski@linux.com>2011-04-30 02:46:03 +0100
commit5da2005d0486838eac2b46afced1f94eda99820a (patch)
treebe80cea4df1a15539157e2d4004906ae62c07a44
parent4b2a0a9e1f214085de5d9d1820ed5c94cb26325b (diff)
Moved to unless from if not to make code more clear. Plus a variable
name change for simplicity. Signed-off-by: Krzysztof Wilczynski <krzysztof.wilczynski@linux.com>
-rw-r--r--shuffle.rb10
1 files changed, 5 insertions, 5 deletions
diff --git a/shuffle.rb b/shuffle.rb
index 2bba584..73e798c 100644
--- a/shuffle.rb
+++ b/shuffle.rb
@@ -13,20 +13,20 @@ module Puppet::Parser::Functions
value = arguments[0]
klass = value.class
- if not [Array, String].include?(klass)
- raise(Puppet::ParseError, 'shuffle(): Requires either an ' +
+ unless [Array, String].include?(klass)
+ raise(Puppet::ParseError, 'shuffle(): Requires either ' +
'array or string to work with')
end
result = value.clone
- string_type = value.is_a?(String) ? true : false
+ string = value.is_a?(String) ? true : false
# Check whether it makes sense to shuffle ...
return result if result.size <= 1
# We turn any string value into an array to be able to shuffle ...
- result = string_type ? result.split('') : result
+ result = string ? result.split('') : result
elements = result.size
@@ -36,7 +36,7 @@ module Puppet::Parser::Functions
result[j], result[i] = result[i], result[j]
end
- result = string_type ? result.join : result
+ result = string ? result.join : result
return result
end