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