Cldr.Unit.decompose
You're seeing just the function
decompose
, go back to Cldr.Unit module for more information.
Specs
Decomposes a unit into subunits.
Any list compatible units can be provided
however a list of units of decreasing scale
is recommended. For example [:foot, :inch]
or [:kilometer, :meter, :centimeter, :millimeter]
Arguments
unit
is any unit returned byCldr.Unit.new/2
unit_list
is a list of valid units (one or more from the list returned byCldr.Unit.known_units/0
. All units must be from the same unit category.format_options
is a Keyword list of options that is added to the last unit inunit_list
. Theformat_options
will be applied when callingCldr.Unit.to_string/3
on theunit
. The default is[]
.
Returns
- a list of units after decomposition or an error tuple
Examples
iex> u = Cldr.Unit.new!(10.3, :foot)
iex> Cldr.Unit.decompose u, [:foot, :inch]
[Cldr.Unit.new!(:foot, 10), Cldr.Unit.new!(:inch, Ratio.new(18, 5))]
iex> u = Cldr.Unit.new!(:centimeter, 1111)
iex> Cldr.Unit.decompose u, [:kilometer, :meter, :centimeter, :millimeter]
[Cldr.Unit.new!(:meter, 11), Cldr.Unit.new!(:centimeter, 11)]