Class: Numeric
- Inherits:
-
Object
- Object
- Numeric
- Defined in:
- lib/core_augmentations/Numeric/percentage_of.rb
Instance Method Summary collapse
-
#percentage_of(n, round = 2) ⇒ Object
return the percentage of a number, rounded to 2 places by default.
Instance Method Details
#percentage_of(n, round = 2) ⇒ Object
return the percentage of a number, rounded to 2 places by default.
3 4 5 |
# File 'lib/core_augmentations/Numeric/percentage_of.rb', line 3 def percentage_of(n, round = 2) return (self.to_f / n.to_f * 100.0).round(round) end |