Sha256: 2e3e2b2af7687762a2aac11f68dd23f8a58e3a264455df16d088976724b6634d

Contents?: true

Size: 650 Bytes

Versions: 13

Compression:

Stored size: 650 Bytes

Contents

# encoding: UTF-8

# Copyright 2012 Twitter, Inc
# http://www.apache.org/licenses/LICENSE-2.0

module TwitterCldr
  module Formatters
    class PercentFormatter < NumberFormatter
      DEFAULT_PERCENT_SIGN = "%"

      def initialize(options = {})
        @tokenizer = TwitterCldr::Tokenizers::NumberTokenizer.new(:locale => self.extract_locale(options), :type => :percent)
        super
      end

      def format(number, options = {})
        super(number, options).gsub('ยค', @tokenizer.symbols[:percent_sign] || DEFAULT_PERCENT_SIGN)
      end

      def default_format_options_for(number)
        { :precision => 0 }
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
twitter_cldr-1.9.1 lib/twitter_cldr/formatters/numbers/percent_formatter.rb
twitter_cldr-1.9.0 lib/twitter_cldr/formatters/numbers/percent_formatter.rb
twitter_cldr-1.8.1 lib/twitter_cldr/formatters/numbers/percent_formatter.rb
twitter_cldr-1.8.0 lib/twitter_cldr/formatters/numbers/percent_formatter.rb
twitter_cldr-1.7.0 lib/twitter_cldr/formatters/numbers/percent_formatter.rb
twitter_cldr-1.6.2 lib/twitter_cldr/formatters/numbers/percent_formatter.rb
twitter_cldr-1.6.1 lib/twitter_cldr/formatters/numbers/percent_formatter.rb
twitter_cldr-1.6.0 lib/twitter_cldr/formatters/numbers/percent_formatter.rb
twitter_cldr-1.5.0 lib/twitter_cldr/formatters/numbers/percent_formatter.rb
twitter_cldr-1.4.1 lib/twitter_cldr/formatters/numbers/percent_formatter.rb
twitter_cldr-1.4.0 lib/twitter_cldr/formatters/numbers/percent_formatter.rb
twitter_cldr-1.3.6 lib/twitter_cldr/formatters/numbers/percent_formatter.rb
twitter_cldr-1.3.0 lib/twitter_cldr/formatters/numbers/percent_formatter.rb