Sha256: f8afefc2a61040e365f9a2a392fb76c686ba619e1fc8a554c697839269a6c9dd
Contents?: true
Size: 329 Bytes
Versions: 41
Compression:
Stored size: 329 Bytes
Contents
class Integer # Rounds up to _p_ digits. For graphs. Josh Pencheon 22/08/2007 def round_up_to(p) return nil if p > self.to_s.length || p < 0 p = p.to_i s = self.to_s.split('') d = s[0..(p - 1)] d[p - 1] = s[p - 1].to_i + 1 s[p..-1].each_with_index { |_v, i| d[i + p] = '0' } d.join.to_i end end
Version data entries
41 entries across 41 versions & 1 rubygems
Version | Path |
---|---|
ndr_support-3.1.1 | lib/ndr_support/integer.rb |