]> git.donarmstrong.com Git - dsa-puppet.git/blob - 3rdparty/modules/stdlib/lib/puppet/parser/functions/ceiling.rb
upgrade to stdlib 4.6.1
[dsa-puppet.git] / 3rdparty / modules / stdlib / lib / puppet / parser / functions / ceiling.rb
1 module Puppet::Parser::Functions
2   newfunction(:ceiling, :type => :rvalue, :doc => <<-EOS
3     Returns the smallest integer greater or equal to the argument.
4     Takes a single numeric value as an argument.
5     EOS
6   ) do |arguments|
7
8     raise(Puppet::ParseError, "ceiling(): Wrong number of arguments " +
9           "given (#{arguments.size} for 1)") if arguments.size != 1
10
11     begin
12       arg = Float(arguments[0])
13     rescue TypeError, ArgumentError => e
14       raise(Puppet::ParseError, "ceiling(): Wrong argument type " +
15             "given (#{arguments[0]} for Numeric)")
16     end
17
18     raise(Puppet::ParseError, "ceiling(): Wrong argument type " +
19           "given (#{arg.class} for Numeric)") if arg.is_a?(Numeric) == false
20
21     arg.ceil
22   end
23 end
24
25 # vim: set ts=2 sw=2 et :