Sha256: 1079737c680956ea05b737de7919dcd9002fcc90040050b7ac227150508e0e19

Contents?: true

Size: 289 Bytes

Versions: 3

Compression:

Stored size: 289 Bytes

Contents

Fixnum.class_eval do
  if 0.respond_to? :digits
    def num_digits(base = 10)
      self.digits.count
    end
  else
    def num_digits(base = 10)
      num = self.abs
      if num == 0
        1
      else
        Math.log10(num).floor + 1
      end
    end
  end
end # Fixnum.class_eval

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
green-button-data-1.0.3 lib/green-button-data/core_extensions/fixnum.rb
green-button-data-1.0.1 lib/green-button-data/core_extensions/fixnum.rb
green-button-data-1.0.0 lib/green-button-data/core_extensions/fixnum.rb