Class: Numeric

Inherits:
Object
  • Object
show all
Defined in:
lib/core_augmentations/Numeric/percentage_of.rb

Instance Method Summary collapse

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