Sha256: 2bd2797fa9b38328ee2af332eae98d0a024d116f8a69c302e8c9c1920aa93b95
Contents?: true
Size: 824 Bytes
Versions: 3
Compression:
Stored size: 824 Bytes
Contents
module Polyfill module V2_4 module Integer module Instance module Digits module Method def digits(base = 10) base = base.to_int raise Math::DomainError, 'out of domain' if self < 0 raise ArgumentError, 'negative radix' if base < 0 raise ArgumentError, "invalid radix #{base}" if base < 2 acc = [] remainder = self while remainder > 0 remainder, value = remainder.divmod(base) acc.push(value) end acc end end refine ::Integer do include Method end def self.included(base) base.include Method end end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
polyfill-0.6.0 | lib/polyfill/v2_4/integer/instance/digits.rb |
polyfill-0.5.0 | lib/polyfill/v2_4/integer/instance/digits.rb |
polyfill-0.4.0 | lib/polyfill/v2_4/integer/instance/digits.rb |