From 5da2005d0486838eac2b46afced1f94eda99820a Mon Sep 17 00:00:00 2001 From: Krzysztof Wilczynski Date: Sat, 30 Apr 2011 02:46:03 +0100 Subject: Moved to unless from if not to make code more clear. Plus a variable name change for simplicity. Signed-off-by: Krzysztof Wilczynski --- shuffle.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'shuffle.rb') 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 -- cgit v1.2.3