]> git.donarmstrong.com Git - dsa-puppet.git/blob - 3rdparty/modules/stdlib/lib/puppet/parser/functions/bool2str.rb
upgrade to stdlib 4.6.1
[dsa-puppet.git] / 3rdparty / modules / stdlib / lib / puppet / parser / functions / bool2str.rb
1 #
2 # bool2str.rb
3 #
4
5 module Puppet::Parser::Functions
6   newfunction(:bool2str, :type => :rvalue, :doc => <<-EOS
7     Converts a boolean to a string.
8     Requires a single boolean as an input.
9     EOS
10   ) do |arguments|
11
12     raise(Puppet::ParseError, "bool2str(): Wrong number of arguments " +
13       "given (#{arguments.size} for 1)") if arguments.size < 1
14
15     value = arguments[0]
16     klass = value.class
17
18     # We can have either true or false, and nothing else
19     unless [FalseClass, TrueClass].include?(klass)
20       raise(Puppet::ParseError, 'bool2str(): Requires a boolean to work with')
21     end
22
23     return value.to_s
24   end
25 end
26
27 # vim: set ts=2 sw=2 et :