Class: Mack::Localization::NumberAndCurrencyFormatEngine::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/mack-localization/format_engine/nc_engines/base.rb

Direct Known Subclasses

BP, DE, EN, ES, FR, IT

Instance Method Summary collapse

Instance Method Details

#format_currency(num, lang) ⇒ Object



6
7
8
9
# File 'lib/mack-localization/format_engine/nc_engines/base.rb', line 6

def format_currency(num, lang)
  currency = "#{unit}#{format_number(num, lang)}"
  return currency
end

#format_number(num, lang) ⇒ Object



11
12
13
14
15
16
# File 'lib/mack-localization/format_engine/nc_engines/base.rb', line 11

def format_number(num, lang)
  num_str = "%01.2f" % num
  parts = num_str.split(".")
  parts[0].gsub!(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1#{delimiter}")
  parts.join separator
end