def currency(number, opts = {})
      return if number.to_s.empty?

      unit      = opts[:unit]      || settings.default_currency_unit
      precision = opts[:precision] || settings.default_currency_precision
      separator = opts[:separator] || settings.default_currency_separator

      ret = "%s %.#{ Integer(precision) }f" % [unit, number]
      parts = ret.split('.')
      parts[0].gsub!(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1#{separator}")
      parts.join('.')
    end
def currency(number, opts = {})
      return if number.to_s.empty?

      unit      = opts[:unit]      || settings.default_currency_unit
      precision = opts[:precision] || settings.default_currency_precision
      separator = opts[:separator] || settings.default_currency_separator

      ret = "%s %.#{ Integer(precision) }f" % [unit, number]
      parts = ret.split('.')
      parts[0].gsub!(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1#{separator}")
      parts.join('.')
    end
Formats a number into a currency display. Uses the following settings:

 - settings.default_currency_unit      (defaults to '$')
 - settings.default_currency_precision (defaults to 2)
 - settings.default_currenty_separator (defaults to ',')

 @example

   currency(100) == "$ 100.00"
   # => true

   currency(100, :unit => "&pound;") == "&pound; 100.00"
   # => true

   currency(100, :precision => 0) == "$ 100"
   => # true

   # somewhere in your sinatra context after registering Sinatra::Helpers
   set :default_currency_unit, '&pound;'
   set :default_currency_precision, 3
   set :default_currency_separator, ' '

   currency(100) == "&pound; 100.000"
   # => true

 @param [Numeric] number the number you wish to display as a currency.
 @param [Hash] opts the various options available.
 @option opts [#to_s] :unit (defaults to '$')
 @option opts [Fixnum] :precision (defaults to 2)
 @option opts [#to_s] :separator (defaults to ',')
 @return [String] the formatted string based on `number`.
 @return [nil] if given nil or an empty string.