Localize.Number.Format.Meta (Localize v0.48.0)

Copy Markdown View Source

Describes the metadata that drives number formatting and provides functions to update the struct.

The metadata is derived from parsing a number format pattern (e.g., "#,##0.###") and captures all the information needed to format a number: digit counts, grouping, rounding, padding, multiplier, and the positive/negative format templates. It is returned by Localize.Number.Format.Compiler.format_to_metadata/1 and its type appears in that module's public interface, so it is part of the documented API.

Summary

Functions

Returns a new number formatting metadata struct with default values.

Types

t()

@type t() :: %Localize.Number.Format.Meta{
  currency: nil | map(),
  engineering_grouping: non_neg_integer(),
  exponent_digits: non_neg_integer(),
  exponent_sign: boolean(),
  format: [{:negative, [any(), ...]} | {:positive, [any(), ...]}, ...],
  fractional_digits: %{max: non_neg_integer(), min: non_neg_integer()},
  grouping: %{
    fraction: %{first: non_neg_integer(), rest: non_neg_integer()},
    integer: %{first: non_neg_integer(), rest: non_neg_integer()}
  },
  integer_digits: %{max: non_neg_integer(), min: non_neg_integer()},
  multiplier: non_neg_integer(),
  number: non_neg_integer(),
  padding_char: String.t(),
  padding_length: non_neg_integer(),
  round_nearest: non_neg_integer(),
  scientific_rounding: non_neg_integer(),
  significant_digits: %{max: non_neg_integer(), min: non_neg_integer()}
}

Functions

new()

@spec new() :: t()

Returns a new number formatting metadata struct with default values.

Returns

  • A Localize.Number.Format.Meta.t() struct.

Examples

iex> meta = Localize.Number.Format.Meta.new()
iex> meta.integer_digits
%{min: 1, max: 0}
iex> meta.multiplier
1