Last change
on this file since 30960 was 30960, checked in by davidb, 8 years ago |
Switch to using Puppet to provision machine. Strongly based on files developed for spark-hdfs cluster
|
File size:
780 bytes
|
Rev | Line | |
---|
[30960] | 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 :
|
---|
Note:
See
TracBrowser
for help on using the repository browser.