diff options
author | Krzysztof Wilczynski <krzysztof.wilczynski@linux.com> | 2011-04-30 00:59:18 +0100 |
---|---|---|
committer | Krzysztof Wilczynski <krzysztof.wilczynski@linux.com> | 2011-04-30 00:59:18 +0100 |
commit | 21e39aaeac2fb545b80a47f55f5e77a2872f65fc (patch) | |
tree | 04a45cfb62457b3b8fc98b42a7928d1eb6b15a8b /unique.rb | |
parent | 551f4ce95b5a7b141d40e654026ff3b000481096 (diff) | |
download | puppet-stdlib-21e39aaeac2fb545b80a47f55f5e77a2872f65fc.tar.gz puppet-stdlib-21e39aaeac2fb545b80a47f55f5e77a2872f65fc.tar.bz2 |
Moved to unless from if not plus removed surplus empty lines.
Signed-off-by: Krzysztof Wilczynski <krzysztof.wilczynski@linux.com>
Diffstat (limited to 'unique.rb')
-rw-r--r-- | unique.rb | 14 |
1 files changed, 6 insertions, 8 deletions
@@ -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 |