Sha256: 4bb7176eba7ee12631af477f528e0fc64078d782dfdafd5065540754fda2af5e

Contents?: true

Size: 571 Bytes

Versions: 1

Compression:

Stored size: 571 Bytes

Contents

module Polyfill
  module V2_4
    module Float
      module Ceil
        module Method
          def ceil(ndigits = 0)
            ndigits = ndigits.to_int
            return super() if ndigits == 0

            if ndigits > 0
              place = 10 ** ndigits
              (self * place).ceil / place.to_f
            else
              place = 10 ** -ndigits
              (self.to_f / place).ceil * place
            end
          end if RUBY_VERSION < '2.4.0'
        end

        refine ::Float do
          include Method
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
polyfill-0.1.0 lib/polyfill/v2_4/float/ceil.rb