AutoApi.UnitType (auto_api v13.2.0) View Source
Handles unit types
Link to this section Summary
Functions
Returns all measurement types
Returns the ID of a measurement type given the name.
Returns the name of a measurement type given its ID
Returns the ID of an unit of measurement.
Returns the name of an unit of measurement.
Returns all possible units for the given measurement type.
Link to this section Types
Specs
Specs
Specs
Specs
Specs
Specs
Specs
Specs
Specs
Specs
Specs
id() :: 1..255
Specs
Specs
Specs
Specs
Specs
Specs
Specs
Specs
Specs
Specs
Link to this section Functions
Specs
all() :: [atom()]
Returns all measurement types
Example
iex> types = AutoApi.UnitType.all()
iex> length(types)
19
iex> List.first(types)
:acceleration
Specs
Returns the ID of a measurement type given the name.
The name can be expressed as a string or atom.
Examples
iex> AutoApi.UnitType.id(:length)
0x12
iex> AutoApi.UnitType.id("power")
0x14
Specs
Returns the name of a measurement type given its ID
Example
iex> AutoApi.UnitType.name(0x18)
:torque
Specs
Returns the ID of an unit of measurement.
The measurement name can be passed either as string or atom, but the unit name is only accepted in atom format.
Examples
iex> AutoApi.UnitType.unit_id(:volume, :liters)
0x02
iex> AutoApi.UnitType.unit_id("power", :megawatts)
0x03
iex> AutoApi.UnitType.unit_id("power", :foobar)
nil
Specs
Returns the name of an unit of measurement.
Both the type and unit must be specified by their IDs.
Example
iex> AutoApi.UnitType.unit_name(0x16, 0x02)
:miles_per_hour
Specs
Returns all possible units for the given measurement type.
The type can be specified either by ID or name (string or atom).
Examples
iex> AutoApi.UnitType.units(:speed) |> List.first()
:meters_per_second
iex> AutoApi.UnitType.units("torque") |> List.first()
:newton_meters
iex> AutoApi.UnitType.units(0x11) |> List.first()
:lux