Sha256: dbab963cf70c622f5f2cd727e5ef6b22884f1db72c7bfd5dc71d2cf300a32405
Contents?: true
Size: 698 Bytes
Versions: 1
Compression:
Stored size: 698 Bytes
Contents
module Polyfill module V2_4 module Integer module Round module Method def round(ndigits = 0, half: nil) unless [nil, :down, :even, :up, 'down', 'even', 'up'].include?(half) raise ArgumentError, "invalid rounding mode: #{half}" end ndigits = ndigits.to_int return super() if ndigits == 0 return to_f if ndigits > 0 place = 10 ** -ndigits (self.to_f / place).round * place end if RUBY_VERSION < '2.4.0' end if RUBY_VERSION < '2.4.0' refine ::Integer do include Method end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
polyfill-0.2.0 | lib/polyfill/v2_4/integer/round.rb |