]> gitweb.fluxo.info Git - puppet-stdlib.git/commitdiff
Moved to unless from if not to make code more clear. Plus a variable
authorKrzysztof Wilczynski <krzysztof.wilczynski@linux.com>
Sat, 30 Apr 2011 01:46:03 +0000 (02:46 +0100)
committerKrzysztof Wilczynski <krzysztof.wilczynski@linux.com>
Sat, 30 Apr 2011 01:46:03 +0000 (02:46 +0100)
name change for simplicity.

Signed-off-by: Krzysztof Wilczynski <krzysztof.wilczynski@linux.com>
shuffle.rb

index 2bba584af2061c1c923f9ce601c52495c1da93dc..73e798c91afbf6f2107dfaf42c0f8f5549e73310 100644 (file)
@@ -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