diff options
author | Krzysztof Wilczynski <krzysztof.wilczynski@linux.com> | 2011-04-30 02:46:03 +0100 |
---|---|---|
committer | Krzysztof Wilczynski <krzysztof.wilczynski@linux.com> | 2011-04-30 02:46:03 +0100 |
commit | 5da2005d0486838eac2b46afced1f94eda99820a (patch) | |
tree | be80cea4df1a15539157e2d4004906ae62c07a44 | |
parent | 4b2a0a9e1f214085de5d9d1820ed5c94cb26325b (diff) | |
download | puppet-stdlib-5da2005d0486838eac2b46afced1f94eda99820a.tar.gz puppet-stdlib-5da2005d0486838eac2b46afced1f94eda99820a.tar.bz2 |
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.rb | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -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 |