Puppet Function: bacula::yesno2str
- Defined in:
- lib/puppet/functions/bacula/yesno2str.rb
- Function type:
- Ruby 4.x API
Overview
Convert various representations of ‘yes’ and ‘no’ to ‘yes’ and ‘no’.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/puppet/functions/bacula/yesno2str.rb', line 4 Puppet::Functions.create_function(:'bacula::yesno2str') do # @param value A boolean value # @return [String] Either 'yes' or 'no' # @example # bacula::yesno2str(true) #=> 'yes' # bacula::yesno2str('true') #=> 'yes' # bacula::yesno2str('yes') #=> 'yes' # bacula::yesno2str(false) #=> 'no' # bacula::yesno2str('false') #=> 'no' # bacula::yesno2str('no') #=> 'no' dispatch :yesno2str do param 'Variant[Boolean, Enum["yes", "true", "no", "false"]]', :value return_type 'String' end def yesno2str(value) case value when true, 'true', 'yes' then 'yes' when false, 'false', 'no' then 'no' else raise "Unexpected value #{value}" end end end |