Module: Taxedo::Builder::Price
- Defined in:
- lib/taxedo/builder/price.rb
Class Method Summary collapse
Class Method Details
.currency_symbol(unit) ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/taxedo/builder/price.rb', line 4 def self.currency_symbol(unit) return case unit.downcase when 'cad', 'usd' then '$' when 'eur' then '€' when 'chf' then 'CHF' else '' end end |
.price(amount, options = {}) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/taxedo/builder/price.rb', line 13 def self.price(amount, ={}) = { separator: ',', format: '%n%u', unit: 'cad' }.merge() result = amount.to_s.rjust(3,'0') result = result[0..-3] + [:separator] + result[-2..-1] result = [:format].gsub('%u', currency_symbol([:unit])).gsub('%n', result) if [:unit] return result end |