4 module Puppet::Parser::Functions
5 newfunction(:is_float, :type => :rvalue, :doc => <<-DOC
6 Returns true if the variable passed to this function is a float.
10 function_deprecation([:is_float, 'This method is deprecated, please use the stdlib validate_legacy function,
11 with Stdlib::Compat::Float. There is further documentation for validate_legacy function in the README.'])
13 if arguments.size != 1
14 raise(Puppet::ParseError, "is_float(): Wrong number of arguments given #{arguments.size} for 1")
19 # Only allow Numeric or String types
20 return false unless value.is_a?(Numeric) || value.is_a?(String)
22 return false if value != value.to_f.to_s && !value.is_a?(Float)
27 # vim: set ts=2 sw=2 et :