Sha256: a2b3004f40d367643ba12f118190e2e2df64c08bdf5f02a67152e0738b786320

Contents?: true

Size: 488 Bytes

Versions: 367

Compression:

Stored size: 488 Bytes

Contents

# Returns an `Integer` value rounded to the nearest value.
# Takes a single `Numeric` value as an argument.
#
# @example 'rounding a value'
#
# ```puppet
# notice(round(2.9)) # would notice 3
# notice(round(2.1)) # would notice 2
# notice(round(-2.9)) # would notice -3
# ```
#
Puppet::Functions.create_function(:round) do
  dispatch :on_numeric do
    param 'Numeric', :val
  end

  def on_numeric(x)
    if x > 0
      Integer(x + 0.5)
    else
      Integer(x - 0.5)
    end
  end
end

Version data entries

367 entries across 367 versions & 2 rubygems

Version Path
puppet-7.34.0 lib/puppet/functions/round.rb
puppet-7.34.0-x86-mingw32 lib/puppet/functions/round.rb
puppet-7.34.0-x64-mingw32 lib/puppet/functions/round.rb
puppet-7.34.0-universal-darwin lib/puppet/functions/round.rb
puppet-7.33.0 lib/puppet/functions/round.rb
puppet-7.33.0-x86-mingw32 lib/puppet/functions/round.rb
puppet-7.33.0-x64-mingw32 lib/puppet/functions/round.rb
puppet-7.33.0-universal-darwin lib/puppet/functions/round.rb
puppet-7.32.1 lib/puppet/functions/round.rb
puppet-7.32.1-x86-mingw32 lib/puppet/functions/round.rb
puppet-7.32.1-x64-mingw32 lib/puppet/functions/round.rb
puppet-7.32.1-universal-darwin lib/puppet/functions/round.rb
puppet-7.31.0 lib/puppet/functions/round.rb
puppet-7.31.0-x86-mingw32 lib/puppet/functions/round.rb
puppet-7.31.0-x64-mingw32 lib/puppet/functions/round.rb
puppet-7.31.0-universal-darwin lib/puppet/functions/round.rb
puppet-7.30.0 lib/puppet/functions/round.rb
puppet-7.30.0-x86-mingw32 lib/puppet/functions/round.rb
puppet-7.30.0-x64-mingw32 lib/puppet/functions/round.rb
puppet-7.30.0-universal-darwin lib/puppet/functions/round.rb