Sha256: cbcb3cbe3b5e80cded33326673949cfce1c857462827e76f0398e351b4e8b53d

Contents?: true

Size: 237 Bytes

Versions: 2

Compression:

Stored size: 237 Bytes

Contents

module PercentOf
  def percent_of(total)
    raise RuntimeError, 'total cand be 0' if total.to_f == 0.0
    sprintf '%.2f%', self / total.to_f * 100
  end
end

class Float ; include PercentOf ; end
class Fixnum ; include PercentOf ; end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
percent_of-0.0.2 lib/percent_of.rb
percent_of-0.0.1 lib/percent_of.rb