Sha256: 7a943aa6e031538fe4dd1cc8f72b97d516b01294b340b0a20db02651c0f13063
Contents?: true
Size: 812 Bytes
Versions: 26
Compression:
Stored size: 812 Bytes
Contents
#-- # Credit goes to George Moschovitis #++ class Numeric # Returns the multiple ceil of a number. def ceil_multiple(multiple) # gmosx: to_f is needed! # gmosx: IS THERE a more optimized way to do this? return ((self.to_f/multiple).ceil*multiple) end end # _____ _ # |_ _|__ ___| |_ # | |/ _ \/ __| __| # | | __/\__ \ |_ # |_|\___||___/\__| # =begin test require 'test/unit' class TCNumeric < Test::Unit::TestCase def test_ceil_multiple assert_equal( 12.3, 12.3.ceil_multiple(0.1) ) assert_equal( 12.4, 12.31.ceil_multiple(0.1) ) assert_equal( 13, 12.3.ceil_multiple(1) ) assert_equal( 13, 12.31.ceil_multiple(1) ) assert_equal( 20, 12.3.ceil_multiple(10) ) assert_equal( 20, 12.31.ceil_multiple(10) ) end end =end
Version data entries
26 entries across 26 versions & 1 rubygems