source: other-projects/hathitrust/vagrant-hadoop-cluster/trunk/modules/stdlib/lib/puppet/parser/functions/bool2num.rb@ 30903

Last change on this file since 30903 was 30903, checked in by davidb, 8 years ago

Vagrant provisioning files for a 4-node Hadoop cluster. See README.txt for more details

File size: 629 bytes
Line 
1#
2# bool2num.rb
3#
4
5module Puppet::Parser::Functions
6 newfunction(:bool2num, :type => :rvalue, :doc => <<-EOS
7 Converts a boolean to a number. Converts the values:
8 false, f, 0, n, and no to 0
9 true, t, 1, y, and yes to 1
10 Requires a single boolean or string as an input.
11 EOS
12 ) do |arguments|
13
14 raise(Puppet::ParseError, "bool2num(): Wrong number of arguments " +
15 "given (#{arguments.size} for 1)") if arguments.size < 1
16
17 value = function_str2bool([arguments[0]])
18
19 # We have real boolean values as well ...
20 result = value ? 1 : 0
21
22 return result
23 end
24end
25
26# vim: set ts=2 sw=2 et :
Note: See TracBrowser for help on using the repository browser.