Last change
on this file since 30903 was 30903, checked in by davidb, 7 years ago |
Vagrant provisioning files for a 4-node Hadoop cluster. See README.txt for more details
|
File size:
869 bytes
|
Line | |
---|
1 | #
|
---|
2 | # is_float.rb
|
---|
3 | #
|
---|
4 |
|
---|
5 | module Puppet::Parser::Functions
|
---|
6 | newfunction(:is_float, :type => :rvalue, :doc => <<-EOS
|
---|
7 | Returns true if the variable passed to this function is a float.
|
---|
8 | EOS
|
---|
9 | ) do |arguments|
|
---|
10 |
|
---|
11 | function_deprecation([:is_float, 'This method is deprecated, please use the stdlib validate_legacy function, with Stdlib::Compat::Float. There is further documentation for validate_legacy function in the README.'])
|
---|
12 |
|
---|
13 | if (arguments.size != 1) then
|
---|
14 | raise(Puppet::ParseError, "is_float(): Wrong number of arguments "+
|
---|
15 | "given #{arguments.size} for 1")
|
---|
16 | end
|
---|
17 |
|
---|
18 | value = arguments[0]
|
---|
19 |
|
---|
20 | # Only allow Numeric or String types
|
---|
21 | return false unless value.is_a?(Numeric) or value.is_a?(String)
|
---|
22 |
|
---|
23 | if value != value.to_f.to_s and !value.is_a? Float then
|
---|
24 | return false
|
---|
25 | else
|
---|
26 | return true
|
---|
27 | end
|
---|
28 |
|
---|
29 | end
|
---|
30 | end
|
---|
31 |
|
---|
32 | # vim: set ts=2 sw=2 et :
|
---|
Note:
See
TracBrowser
for help on using the repository browser.