$k. Measurement

new Measurement(value, scale)

Parameters:
NameTypeDescription
valueobject

The measurement's numeric value in the given unit or a $k.Attribute with base unit.

scaleMeasurementScale

Either the value's Unit or the value's QuantityKind, assuming that the value is given in the QuantityKind's base unit. If the first argument is a $k.Attribute, the attribute's value will be converted to this unit.

Methods

(static) parse(string, QuantityKindopt, languageopt)

Parses a string consisting of a sequence of values and unit symbols. If the parameter quantityKind is not set, the function tries to guess the quantity kind based on the unit symbols used.

Parameters:
NameTypeAttributesDescription
stringstring

The string representation of the measurement

QuantityKindobject<optional>

The optional QuantityKind of the measurement

languagelanguage<optional>

Language of the string

Since
  • 5.4.2

baseValue() → {number}

Since
  • 5.4.2
Returns:

The value in relation to the unit with factor 1.

Type: 
number

quantityKind() → {MeasurementScale}

Returns the quantity kind of the measurement.

Since
  • 5.4.2
Returns:
Type: 
MeasurementScale

toBaseUnit() → {$k.Measurement}

Since
  • 5.4.2
Returns:

A measurement of same absolut value in the measurements's base unit or undefined, if the measurement's quantity kind has no unit with factor 1.

Type: 
$k.Measurement

toUnit(unit, languageopt) → {$k.Measurement}

Returns a measurement of same absolut value in the given unit.

Parameters:
NameTypeAttributesDescription
unit$k.Unit

The target unit

languagestring<optional>

Optional language to determine the target unit

Since
  • 5.4.2
Returns:
Type: 
$k.Measurement

unit() → {MeasurementScale}

Returns the (base) unit of the measurement.

Since
  • 5.4.2
Returns:
Type: 
MeasurementScale

value(unitopt) → {number}

Parameters:
NameTypeAttributesDescription
unit$k.Unit<optional>

Optional unit in which the measurement value is returned.

Since
  • 5.4.0
Returns:

Returns the value of the measurement.

Type: 
number

valueOf()

valueString(unitsopt, languageopt) → {string}

Returns the string representation of the measurement. If the units parameter is not set, the measurement's unit or quantity kind is used.

Parameters:
NameTypeAttributesDescription
unitsarray<optional>

the units to use

languagestring<optional>

the language to use

Since
  • 5.4.0
Returns:
Type: 
string