Class: String

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

Instance Method Summary collapse

Instance Method Details

#absObject



31
32
33
# File 'lib/currency_math.rb', line 31

def abs
  split('-').last
end

#with_trailing_zerosObject



25
26
27
28
29
# File 'lib/currency_math.rb', line 25

def with_trailing_zeros
  s = split('.')
  s.last << '0' while s.last.size < 2 && s.size > 1
  s.join('.')
end