]> git.donarmstrong.com Git - dsa-puppet.git/blob - modules/stdlib/lib/puppet/parser/functions/is_numeric.rb
upgrade to concat 2.0.0
[dsa-puppet.git] / modules / stdlib / lib / puppet / parser / functions / is_numeric.rb
1 #
2 # is_numeric.rb
3 #
4
5 module Puppet::Parser::Functions
6   newfunction(:is_numeric, :type => :rvalue, :doc => <<-EOS
7 Returns true if the variable passed to this function is a number.
8     EOS
9   ) do |arguments|
10
11     if (arguments.size != 1) then
12       raise(Puppet::ParseError, "is_numeric(): Wrong number of arguments "+
13         "given #{arguments.size} for 1")
14     end
15
16     value = arguments[0]
17
18     if value == value.to_f.to_s or value == value.to_i.to_s then
19       return true
20     else
21       return false
22     end
23
24   end
25 end
26
27 # vim: set ts=2 sw=2 et :