Cldr.Unit.unit_category

You're seeing just the function unit_category, go back to Cldr.Unit module for more information.

Specs

unit_category(t() | String.t() | atom()) ::
  {:ok, category()} | {:error, {module(), String.t()}}

Returns the units category for a given unit

Options

Returns

  • {:ok, category} or

  • {:error, {exception, message}}

Examples

iex> Cldr.Unit.unit_category :pint_metric
{:ok, :volume}

iex> Cldr.Unit.unit_category :stone
{:ok, :mass}

iex> Cldr.Unit.unit_category "kilowatt hour"
{:error,
 {Cldr.Unit.UnknownCategoryError,
  "The category for \"kilowatt hour\" is not known."}}