Module: DmUtilities::CurrencyHelper

Includes:
ActionView::Helpers::NumberHelper
Defined in:
app/helpers/dm_utilities/currency_helper.rb

Overview

Currency helper routines


Instance Method Summary collapse

Instance Method Details

#ut_currency(amount, country, options = {}) ⇒ Object

Takes a number and a country code and formats it as a monetary value TODO see if there is a better way to hook in the Globalize::Currency object TODO we’re not using the country object right now - I think this is a problem




10
11
12
13
14
# File 'app/helpers/dm_utilities/currency_helper.rb', line 10

def ut_currency(amount, country, options = {})
  return "—".html_safe if amount.blank?
  precision = options[:precision] || 2
  number_to_currency(amount, :locale => country.locale, :precision => precision)
end

#ut_currency_cents(cents, country, options = {}) ⇒ Object

Takes a number and a country code and formats it as a monetary value




18
19
20
21
# File 'app/helpers/dm_utilities/currency_helper.rb', line 18

def ut_currency_cents(cents, country, options = {})
  return "—".html_safe if cents.blank?
  ut_currency(cents/100, country, options)
end