class CLDR::Numbers::PatternFormatter(Lang)

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.cr

Constructors

Instance Method Summary

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

[View source]

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

[View source]
def format(number : Int) #

Formats a number based on the pattern set by the instance


[View source]
def format(number : Float) #

Formats a number based on the pattern set by the instance


[View source]