module PercentOf

Public Instance Methods

percent_of(total) click to toggle source
# File lib/percent_of.rb, line 2
def percent_of(total)
  raise RuntimeError, "total can't be 0" if total.to_f == 0.0
  sprintf '%.2f%', self / total.to_f * 100
end