From 21e39aaeac2fb545b80a47f55f5e77a2872f65fc Mon Sep 17 00:00:00 2001 From: Krzysztof Wilczynski Date: Sat, 30 Apr 2011 00:59:18 +0100 Subject: Moved to unless from if not plus removed surplus empty lines. Signed-off-by: Krzysztof Wilczynski --- unique.rb | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/unique.rb b/unique.rb index ce7ea70..a922c94 100644 --- a/unique.rb +++ b/unique.rb @@ -13,21 +13,19 @@ module Puppet::Parser::Functions value = arguments[0] klass = value.class - if not [Array, String].include?(klass) - raise(Puppet::ParseError, 'unique(): Requires either an ' + + unless [Array, String].include?(klass) + raise(Puppet::ParseError, 'unique(): 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 # We turn any string value into an array to be able to shuffle ... - result = string_type ? result.split('') : result - - result = result.uniq - - result = string_type ? result.join : result + result = string ? result.split('') : result + result = result.uniq # Remove duplicates ... + result = string ? result.join : result return result end -- cgit v1.2.3