Skip to main content

MetricUnitKinds

The named kinds of measurement, such as "length" and "speed": each a set of dimensions, absolute or a difference. MetricUnit.GetKind, MetricUnit.isKind and MetricUnit.expect take these names. The dimension functions they are built from are in MetricUnitDimensionUtils.

MetricUnitKinds.SPEED -- { length = 1, time = -1 }
MetricUnitKinds.fromName("speed") -- { length = 1, time = -1 }, false
MetricUnitKinds.getKind({ temperature = 1 }, true) -- "temperature"

Types​

KindName​

type KindName = "none" | "time" | "length" | "area" | "volume" | "memory" | "mass" | "rate" | "speed" | "acceleration" | "force" | "energy" | "power" | "pressure" | "density" | "dataRate" | "temperature" | "temperatureDifference" | "instant" | "angle" | "angularVelocity" | "angularAcceleration" | "current" | "charge" | "voltage" | "resistance" | "conductance" | "capacitance" | "inductance" | "magneticFlux" | "magneticFluxDensity" | "amount" | "luminousIntensity" | "solidAngle" | "luminousFlux" | "illuminance" | "absorbedDose" | "catalyticActivity" | "molarMass" | "molarConcentration" | "fuelEconomy"

A kind's name. "temperature" is an absolute temperature and "temperatureDifference" a difference between two. "time" is a span of time and "instant" a point in time, measured from an epoch the caller chooses. "none" is a plain, dimensionless number.

Functions​

fromName​

MetricUnitKinds.fromName(kind: KindName | Dimensions) → (
boolean--

whether the name is of an absolute value

)

The dimensions a KindName stands for, or the table given, and whether it names an absolute value. Errors on an unknown name.

getKind​

MetricUnitKinds.getKind(
dimensions: Dimensions,
absolute: boolean
) → KindName?

The KindName of dimensions, absolute or a difference, or nil for a compound without a name.

MetricUnitKinds.getKind({ length = 1, time = -1 }, false) -- "speed"
MetricUnitKinds.getKind({ temperature = 1 }, true) -- "temperature"
MetricUnitKinds.getKind({ length = 4 }, false) -- nil

describeKind​

MetricUnitKinds.describeKind(
dimensions: Dimensions,
absolute: boolean
) → string

What a value of dimensions is, absolute or a difference: "absolute temperature", "temperature difference", "instant", "length/time".

Show raw api
{
    "functions": [
        {
            "name": "fromName",
            "desc": "The dimensions a [KindName] stands for, or the table given, and whether it names an absolute value. Errors on an\nunknown name.",
            "params": [
                {
                    "name": "kind",
                    "desc": "",
                    "lua_type": "KindName | Dimensions"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Dimensions"
                },
                {
                    "desc": "whether the name is of an absolute value",
                    "lua_type": "boolean"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 184,
                "path": "src/metricutils/src/Shared/Definitions/MetricUnitKinds.lua"
            }
        },
        {
            "name": "getKind",
            "desc": "The [KindName] of `dimensions`, absolute or a difference, or nil for a compound without a name.\n\n```lua\nMetricUnitKinds.getKind({ length = 1, time = -1 }, false) -- \"speed\"\nMetricUnitKinds.getKind({ temperature = 1 }, true) -- \"temperature\"\nMetricUnitKinds.getKind({ length = 4 }, false) -- nil\n```",
            "params": [
                {
                    "name": "dimensions",
                    "desc": "",
                    "lua_type": "Dimensions"
                },
                {
                    "name": "absolute",
                    "desc": "",
                    "lua_type": "boolean"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "KindName?"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 208,
                "path": "src/metricutils/src/Shared/Definitions/MetricUnitKinds.lua"
            }
        },
        {
            "name": "describeKind",
            "desc": "What a value of `dimensions` is, absolute or a difference: \"absolute temperature\", \"temperature difference\",\n\"instant\", \"length/time\".",
            "params": [
                {
                    "name": "dimensions",
                    "desc": "",
                    "lua_type": "Dimensions"
                },
                {
                    "name": "absolute",
                    "desc": "",
                    "lua_type": "boolean"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 225,
                "path": "src/metricutils/src/Shared/Definitions/MetricUnitKinds.lua"
            }
        }
    ],
    "properties": [],
    "types": [
        {
            "name": "KindName",
            "desc": "A kind's name. `\"temperature\"` is an absolute temperature and `\"temperatureDifference\"` a difference between two.\n`\"time\"` is a span of time and `\"instant\"` a point in time, measured from an epoch the caller chooses. `\"none\"` is\na plain, dimensionless number.",
            "lua_type": "\"none\" | \"time\" | \"length\" | \"area\" | \"volume\" | \"memory\" | \"mass\" | \"rate\" | \"speed\" | \"acceleration\" | \"force\" | \"energy\" | \"power\" | \"pressure\" | \"density\" | \"dataRate\" | \"temperature\" | \"temperatureDifference\" | \"instant\" | \"angle\" | \"angularVelocity\" | \"angularAcceleration\" | \"current\" | \"charge\" | \"voltage\" | \"resistance\" | \"conductance\" | \"capacitance\" | \"inductance\" | \"magneticFlux\" | \"magneticFluxDensity\" | \"amount\" | \"luminousIntensity\" | \"solidAngle\" | \"luminousFlux\" | \"illuminance\" | \"absorbedDose\" | \"catalyticActivity\" | \"molarMass\" | \"molarConcentration\" | \"fuelEconomy\"",
            "source": {
                "line": 32,
                "path": "src/metricutils/src/Shared/Definitions/MetricUnitKinds.lua"
            }
        }
    ],
    "name": "MetricUnitKinds",
    "desc": "The named kinds of measurement, such as `\"length\"` and `\"speed\"`: each a set of dimensions, absolute or a\ndifference. [MetricUnit.GetKind], [MetricUnit.isKind] and [MetricUnit.expect] take these names. The dimension\nfunctions they are built from are in [MetricUnitDimensionUtils].\n\n```lua\nMetricUnitKinds.SPEED -- { length = 1, time = -1 }\nMetricUnitKinds.fromName(\"speed\") -- { length = 1, time = -1 }, false\nMetricUnitKinds.getKind({ temperature = 1 }, true) -- \"temperature\"\n```",
    "source": {
        "line": 15,
        "path": "src/metricutils/src/Shared/Definitions/MetricUnitKinds.lua"
    }
}