Sha256: 3a6d1ffb476cc84d0a15b0abfddbb424881dbc71c7b7326bdea54c4ff19301a2

Contents?: true

Size: 679 Bytes

Versions: 11

Compression:

Stored size: 679 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 format(number, options = {})
        super(number, options).gsub('ยค', @tokenizer.symbols[:percent_sign] || DEFAULT_PERCENT_SIGN)
      end

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

      def get_tokens(obj, options = {})
        opts = options.dup.merge(
          :sign => obj.abs == obj ? :positive : :negative,
          :type => :percent
        )
        @tokenizer.tokens(opts)
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
twitter_cldr-2.4.3 lib/twitter_cldr/formatters/numbers/percent_formatter.rb
twitter_cldr-3.0.0.beta1 lib/twitter_cldr/formatters/numbers/percent_formatter.rb
twitter_cldr-2.4.2 lib/twitter_cldr/formatters/numbers/percent_formatter.rb
twitter_cldr-2.4.1 lib/twitter_cldr/formatters/numbers/percent_formatter.rb
twitter_cldr-2.4.0 lib/twitter_cldr/formatters/numbers/percent_formatter.rb
twitter_cldr-2.2.0 lib/twitter_cldr/formatters/numbers/percent_formatter.rb
twitter_cldr-2.1.1 lib/twitter_cldr/formatters/numbers/percent_formatter.rb
twitter_cldr-2.1.0 lib/twitter_cldr/formatters/numbers/percent_formatter.rb
twitter_cldr-2.0.2 lib/twitter_cldr/formatters/numbers/percent_formatter.rb
twitter_cldr-2.0.1 lib/twitter_cldr/formatters/numbers/percent_formatter.rb
twitter_cldr-2.0.0 lib/twitter_cldr/formatters/numbers/percent_formatter.rb