Last change
on this file since 30960 was 30960, checked in by davidb, 7 years ago |
Switch to using Puppet to provision machine. Strongly based on files developed for spark-hdfs cluster
|
File size:
629 bytes
|
Line | |
---|
1 | #
|
---|
2 | # bool2num.rb
|
---|
3 | #
|
---|
4 |
|
---|
5 | module 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
|
---|
24 | end
|
---|
25 |
|
---|
26 | # vim: set ts=2 sw=2 et :
|
---|
Note:
See
TracBrowser
for help on using the repository browser.