Sha256: cd41d988782e8671cf99b0227a07c62c3d046aa570b7d32f6ee73da83bff3538

Contents?: true

Size: 578 Bytes

Versions: 3

Compression:

Stored size: 578 Bytes

Contents

module Polyfill
  module V2_4
    module Integer
      module Instance
        module Floor
          module Method
            def floor(ndigits = 0)
              ndigits = ndigits.to_int
              return super() if ndigits == 0
              return to_f if ndigits > 0

              place = 10**-ndigits
              (to_f / place).floor * place
            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/floor.rb
polyfill-0.5.0 lib/polyfill/v2_4/integer/instance/floor.rb
polyfill-0.4.0 lib/polyfill/v2_4/integer/instance/floor.rb