Module: N::NumberUtils

Defined in:
lib/n/utils/number.rb

Overview

NumberUtils

Design:

Implement as a module to avoid class polution. You can still Ruby’s advanced features to include the module in your class. Passing the object to act upon allows to check for nil, which isn’t possible if you use self.

Class Method Summary collapse

Class Method Details

.ceil_multiple(num, multiple) ⇒ Object

Returns the multiple ceil of a number



23
24
25
26
27
# File 'lib/n/utils/number.rb', line 23

def self.ceil_multiple(num, multiple)
	# gmosx: to_f is needed!s
	# gmosx: IS THERE a more optimized way to do this?
	return ((num.to_f/multiple).ceil*multiple)
end