Sha256: 368ced2a9f4dcd276712fade241c85ee213f6e3a8e0bd1007b299d02ff37da05
Contents?: true
Size: 861 Bytes
Versions: 1
Compression:
Stored size: 861 Bytes
Contents
module TwitterCldr module Formatters class CurrencyFormatter < NumberFormatter DEFAULT_FORMAT_OPTIONS = { :precision => 2 } DEFAULT_CURRENCY_SYMBOL = "$" def initialize(options = {}) @tokenizer = TwitterCldr::Tokenizers::NumberTokenizer.new(:locale => self.extract_locale(options), :type => :currency) super end def format(number, options = {}) if options[:currency] currency ||= TwitterCldr::Shared::Currencies.for_code(options[:currency]) currency ||= TwitterCldr::Shared::Currencies.for_country(options[:currency]) currency ||= { :symbol => options[:currency] } else currency = { :symbol => DEFAULT_CURRENCY_SYMBOL } end super(number, DEFAULT_FORMAT_OPTIONS.merge(options)).gsub('ยค', currency[:symbol]) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
twitter_cldr-1.0.0 | lib/formatters/numbers/currency_formatter.rb |