class Numeric
Public Instance Methods
percentage_of(n, round = 2)
click to toggle source
return the percentage of a number, rounded to 2 places by default.
# File lib/core_refinements/Numeric/percentage_of.rb, line 6 def percentage_of(n, round = 2) return (self.to_f / n.to_f * 100.0).round(round) end