summaryrefslogtreecommitdiff
path: root/lib/puppet/parser/functions/type.rb
diff options
context:
space:
mode:
authorKen Barber <ken@bob.sh>2011-07-29 22:18:56 +0100
committerKen Barber <ken@bob.sh>2011-07-29 22:18:56 +0100
commit19313b43ea04066a88a0b78e83650ac52785e2e9 (patch)
tree15c8e5de95a4ffa297683a1bdab0d45a1bfb97eb /lib/puppet/parser/functions/type.rb
parentf9634b7f9b03be86e25dc740cdcda754a0d2bf7d (diff)
(#3) Apply missing documentation to more functions.
Diffstat (limited to 'lib/puppet/parser/functions/type.rb')
-rw-r--r--lib/puppet/parser/functions/type.rb19
1 files changed, 17 insertions, 2 deletions
diff --git a/lib/puppet/parser/functions/type.rb b/lib/puppet/parser/functions/type.rb
index 389a056..de6087e 100644
--- a/lib/puppet/parser/functions/type.rb
+++ b/lib/puppet/parser/functions/type.rb
@@ -4,6 +4,13 @@
module Puppet::Parser::Functions
newfunction(:type, :type => :rvalue, :doc => <<-EOS
+Returns the type when passed a variable. Type can be one of:
+
+* string
+* array
+* hash
+* float
+* integer
EOS
) do |arguments|
@@ -22,11 +29,19 @@ module Puppet::Parser::Functions
# We note that Integer is the parent to Bignum and Fixnum ...
result = case klass
- when /^(?:Big|Fix)num$/ then 'Integer'
+ when /^(?:Big|Fix)num$/ then 'integer'
else klass
end
- return result
+ if result == "String" then
+ if value == value.to_i.to_s then
+ result = "Integer"
+ elsif value == value.to_f.to_s then
+ result = "Float"
+ end
+ end
+
+ return result.downcase
end
end