diff options
author | Krzysztof Wilczynski <krzysztof.wilczynski@linux.com> | 2011-04-29 17:30:04 +0100 |
---|---|---|
committer | Krzysztof Wilczynski <krzysztof.wilczynski@linux.com> | 2011-04-29 17:30:04 +0100 |
commit | 14b4ca8de2c8802bc599bb45aca5ecbba5ed98c9 (patch) | |
tree | c300e72f648da463228b051cf169c500ed60bd6c /reverse.rb | |
parent | b3dd2207c3eefe4a74f86188330a0117b6f03da9 (diff) | |
download | puppet-stdlib-14b4ca8de2c8802bc599bb45aca5ecbba5ed98c9.tar.gz puppet-stdlib-14b4ca8de2c8802bc599bb45aca5ecbba5ed98c9.tar.bz2 |
Added support for strings to reverse.
Signed-off-by: Krzysztof Wilczynski <krzysztof.wilczynski@linux.com>
Diffstat (limited to 'reverse.rb')
-rw-r--r-- | reverse.rb | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -2,8 +2,6 @@ # reverse.rb # -# TODO(Krzysztof Wilczynski): Support for strings would be nice too ... - module Puppet::Parser::Functions newfunction(:reverse, :type => :rvalue, :doc => <<-EOS EOS @@ -12,13 +10,15 @@ module Puppet::Parser::Functions raise(Puppet::ParseError, "reverse(): Wrong number of arguments " + "given (#{arguments.size} for 1)") if arguments.size < 1 - array = arguments[0] + value = arguments[0] + klass = value.class - if not array.is_a?(Array) - raise(Puppet::ParseError, 'reverse(): Requires an array to work with') + if not [Array, String].include?(klass) + raise(Puppet::ParseError, 'reverse(): Requires either an ' + + 'array or string to work with') end - result = array.reverse + result = value.reverse return result end |