Class: Percentage

Inherits:
Float
  • Object
show all
Defined in:
lib/stashboxr.rb

Overview

Allows percentages to be inspected and stringified in human form “33.3%”, but kept in a float format for mathmatics

Instance Method Summary collapse

Instance Method Details

#to_s(decimalplaces = 0) ⇒ Object Also known as: inspect



7
8
9
# File 'lib/stashboxr.rb', line 7

def to_s(decimalplaces = 0)
  (((self * 10**(decimalplaces+2)).round)/10**decimalplaces).to_s+"%"
end