class CLDR::Numbers::PatternFormatter(Lang)
- CLDR::Numbers::PatternFormatter(Lang)
- Reference
- Object
Overview
EXPERIMENTAL
Formatter for formatting decimal numbers with the attributes from the selected language, and the parsed results from a pattern.
rules, metadata = CLDR::Numbers::PatternParser.new("#,##0.###").parse
formatter = CLDR::Numbers::PatternFormatter(CLDR::Languages::EN).new(rules, metadata)
Defined in:
cldr/logic/numbers/formatter.crConstructors
-
.new(instructions : PatternConstruct, metadata : Metadata)
Initializes a decimal formatter with the parsed results from the
PatternParser
.
Instance Method Summary
-
#format(number : String)
Formats a number (given as string) based on the pattern set by the instance.
-
#format(number : Int)
Formats a number based on the pattern set by the instance
-
#format(number : Float)
Formats a number based on the pattern set by the instance
Constructor Detail
def self.new(instructions : PatternConstruct, metadata : Metadata)
#
Initializes a decimal formatter with the parsed results from the PatternParser
.
rules, metadata = CLDR::Numbers::PatternParser.new("#,##0.###").parse
formatter = CLDR::Numbers::PatternFormatter(CLDR::Languages::EN).new(rules, metadata)
formatter.format("12345") # => 12,345
formatter.format("1000.1236") # => 1,000.124
Instance Method Detail
def format(number : String)
#
Formats a number (given as string) based on the pattern set by the instance.
rules, metadata = CLDR::Numbers::PatternParser.new("#,##0.###").parse
formatter = CLDR::Numbers::PatternFormatter(CLDR::Languages::EN).new(rules, metadata)
formatter.format("12345") # => 12,345
formatter.format("1000.1236") # => 1,000.124