Class: Plurimath::Formatter::Standard

Inherits:
NumberFormatter show all
Defined in:
lib/plurimath/formatter/standard.rb

Constant Summary collapse

DEFAULT_OPTIONS =
{
  fraction_group_digits: 3,
  exponent_sign: nil,
  fraction_group: "'",
  number_sign: nil,
  notation: :basic,
  padding: "0",
  group_digits: 3,
  significant: 0,
  digit_count: 0,
  precision: 0,
  decimal: ".",
  group: ",",
  times: "x",
  e: "e",
}.freeze

Instance Attribute Summary

Attributes inherited from NumberFormatter

#locale, #localize_number, #localizer_symbols, #precision

Instance Method Summary collapse

Methods inherited from NumberFormatter

#localized_number, #twitter_cldr_reader

Constructor Details

#initialize(locale: "en", string_format: nil, options: {}, precision: nil) ⇒ Standard

Returns a new instance of Standard.



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/plurimath/formatter/standard.rb', line 23

def initialize(
  locale: "en",
  string_format: nil,
  options: {},
  precision: nil
)
  super(
    locale,
    localize_number: string_format,
    localizer_symbols: set_default_options(options),
    precision: precision,
  )
end

Instance Method Details

#set_default_options(options) ⇒ Object



37
38
39
40
41
# File 'lib/plurimath/formatter/standard.rb', line 37

def set_default_options(options)
  options = options ? options.dup : {}
  apply_default_symbols(options)
  options
end