Sha256: 52d4fab3f7fe2b53ae792f059a82c24840739b7995634464d7d2992488ffe240

Contents?: true

Size: 278 Bytes

Versions: 5

Compression:

Stored size: 278 Bytes

Contents

# frozen_string_literal: true

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

class Numeric
  include Darthjee::CoreExt::Numeric
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
darthjee-core_ext-1.7.4 lib/darthjee/core_ext/numeric.rb
darthjee-core_ext-1.7.3 lib/darthjee/core_ext/numeric.rb
darthjee-core_ext-1.7.2 lib/darthjee/core_ext/numeric.rb
darthjee-core_ext-1.7.1 lib/darthjee/core_ext/numeric.rb
darthjee-core_ext-1.7.0 lib/darthjee/core_ext/numeric.rb