Sha256: d930fa30786385522ec77a85b1aaefff16ef6f1c70db34918a6019ca3ea659af

Contents?: true

Size: 622 Bytes

Versions: 1

Compression:

Stored size: 622 Bytes

Contents

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

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

        if RUBY_VERSION < '2.4.0'
          refine ::Float 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/float/floor.rb