Class: TwitterCldr::Formatters::PercentFormatter
- Inherits:
-
NumberFormatter
- Object
- Base
- NumberFormatter
- TwitterCldr::Formatters::PercentFormatter
- Defined in:
- lib/twitter_cldr/formatters/numbers/percent_formatter.rb
Constant Summary collapse
- DEFAULT_PERCENT_SIGN =
"%"
Constants inherited from NumberFormatter
NumberFormatter::DEFAULT_SYMBOLS
Instance Attribute Summary
Attributes inherited from NumberFormatter
Attributes inherited from Base
Instance Method Summary collapse
- #default_format_options_for(number) ⇒ Object
- #format(number, options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ PercentFormatter
constructor
A new instance of PercentFormatter.
Constructor Details
#initialize(options = {}) ⇒ PercentFormatter
Returns a new instance of PercentFormatter.
11 12 13 14 |
# File 'lib/twitter_cldr/formatters/numbers/percent_formatter.rb', line 11 def initialize( = {}) @tokenizer = TwitterCldr::Tokenizers::NumberTokenizer.new(:locale => self.extract_locale(), :type => :percent) super end |
Instance Method Details
#default_format_options_for(number) ⇒ Object
20 21 22 |
# File 'lib/twitter_cldr/formatters/numbers/percent_formatter.rb', line 20 def (number) { :precision => 0 } end |
#format(number, options = {}) ⇒ Object
16 17 18 |
# File 'lib/twitter_cldr/formatters/numbers/percent_formatter.rb', line 16 def format(number, = {}) super(number, ).gsub('ยค', @tokenizer.symbols[:percent_sign] || DEFAULT_PERCENT_SIGN) end |