Module: TNB::Math
- Defined in:
- lib/TheresNoBox/tnb.rb
Class Method Summary collapse
-
.to_currency(amount) ⇒ Object
amount is expected to be an integer.
Class Method Details
.to_currency(amount) ⇒ Object
amount is expected to be an integer.
13 14 15 16 17 18 |
# File 'lib/TheresNoBox/tnb.rb', line 13 def self.to_currency(amount) amount = (amount + 0.5).floor dollars = (amount / 100).floor cents = sprintf('%02d', (amount - (dollars * 100))) return '$' << dollars.to_s << '.' << cents end |