Module: Percentise
- Defined in:
- lib/percentise.rb
Overview
Percentise
Constant Summary collapse
- VERSION =
"0.1.2"
Class Method Summary collapse
Class Method Details
.diff(top, bottom) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/percentise.rb', line 17 def self.diff(top, bottom) # if either is nil, then it is nil if top && bottom self.this(top - bottom, bottom) end end |
.this(top, bottom) ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/percentise.rb', line 6 def self.this(top, bottom) if top && bottom if bottom == 0 top_sign = top.to_f <=> 0 top_sign * 100.0 else 100.0 * top.to_f / bottom.to_f end end end |