Module: Percentise

Defined in:
lib/percentise.rb

Overview

Percentise

Class Method Summary collapse

Class Method Details

.diff(top, bottom) ⇒ Object



15
16
17
# File 'lib/percentise.rb', line 15

def self.diff(top, bottom)
  self.this(top - bottom, bottom)
end

.this(top, bottom) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'lib/percentise.rb', line 4

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