Sha256: 00a839f991766e08bddf0a85a0fcc36b87c8490d624da6638f5732f35d2920e2

Contents?: true

Size: 685 Bytes

Versions: 3

Compression:

Stored size: 685 Bytes

Contents

module Polyfill
  module V2_4
    module Float
      module Instance
        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 / place).ceil * place
              end
            end
          end

          refine ::Float 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/float/instance/ceil.rb
polyfill-0.5.0 lib/polyfill/v2_4/float/instance/ceil.rb
polyfill-0.4.0 lib/polyfill/v2_4/float/instance/ceil.rb