Class: TwitterCldr::Formatters::DecimalFormatter

Inherits:
NumberFormatter show all
Defined in:
lib/twitter_cldr/formatters/numbers/decimal_formatter.rb

Constant Summary

Constants inherited from NumberFormatter

NumberFormatter::DEFAULT_SYMBOLS

Instance Attribute Summary

Attributes inherited from NumberFormatter

#symbols

Attributes inherited from Base

#tokenizer

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ DecimalFormatter

Returns a new instance of DecimalFormatter.


9
10
11
12
# File 'lib/twitter_cldr/formatters/numbers/decimal_formatter.rb', line 9

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

Instance Method Details

#default_format_options_for(number) ⇒ Object


20
21
22
# File 'lib/twitter_cldr/formatters/numbers/decimal_formatter.rb', line 20

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

#format(number, options = {}) ⇒ Object


14
15
16
17
18
# File 'lib/twitter_cldr/formatters/numbers/decimal_formatter.rb', line 14

def format(number, options = {})
  super(number, options)
rescue TypeError, ArgumentError
  number
end