Update stdlib and concat to 6.1.0 both
[mirror/dsa-puppet.git] / 3rdparty / modules / stdlib / lib / puppet / parser / functions / ceiling.rb
1 #
2 #  ceiling.rb
3 #
4 module Puppet::Parser::Functions
5   newfunction(:ceiling, :type => :rvalue, :doc => <<-DOC
6     @summary
7       **Deprecated** Returns the smallest integer greater or equal to the argument.
8     Takes a single numeric value as an argument.
9
10     > *Note:*
11       **Deprecated** from Puppet 6.0.0, this function has been replaced with a
12       built-in [`ceiling`](https://puppet.com/docs/puppet/latest/function.html#ceiling) function.
13
14     @return [Integer] The rounded value
15     DOC
16              ) do |arguments|
17
18     raise(Puppet::ParseError, "ceiling(): Wrong number of arguments given (#{arguments.size} for 1)") if arguments.size != 1
19
20     begin
21       arg = Float(arguments[0])
22     rescue TypeError, ArgumentError => _e
23       raise(Puppet::ParseError, "ceiling(): Wrong argument type given (#{arguments[0]} for Numeric)")
24     end
25
26     raise(Puppet::ParseError, "ceiling(): Wrong argument type given (#{arg.class} for Numeric)") if arg.is_a?(Numeric) == false
27
28     arg.ceil
29   end
30 end
31
32 # vim: set ts=2 sw=2 et :