Sha256: 3a4f81a29ed2062f2f0748d0717e8a57bacf29a63b9ad4c64f043304c594fe0a

Contents?: true

Size: 154 Bytes

Versions: 3

Compression:

Stored size: 154 Bytes

Contents

# frozen_string_literal: true

class Numeric
  def percent_of(total)
    return Float::INFINITY if total&.zero?
    (to_f / total.to_f) * 100.0
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
darthjee-core_ext-1.6.2 lib/darthjee/core_ext/numeric.rb
darthjee-core_ext-1.6.1 lib/darthjee/core_ext/numeric.rb
darthjee-core_ext-1.6.0 lib/darthjee/core_ext/numeric.rb