Class FuelConsumptionUnit
Extends
Measurement.
Create a new fuelconsumption measurement instance.
Defined in: FuelConsumptionUnit.js.
Constructor Attributes | Constructor Name and Description |
---|---|
FuelConsumptionUnit(options)
|
Method Attributes | Method Name and Description |
---|---|
convert(to)
Return a new measurement instance that is converted to a new
measurement unit.
|
|
<static> |
FuelConsumptionUnit.convert(to, from, fuelConsumption)
Convert a FuelConsumption to another measure.
|
expand(measurementsystem, units)
Expand the current measurement such that any fractions of the current unit
are represented in terms of smaller units in the same system instead of fractions
of the current unit.
|
|
Return the type of this measurement.
|
|
newUnit(params)
Return a new instance of this type of measurement.
|
|
scale(measurementsystem, units)
Scale the measurement unit to an acceptable level.
|
Class Detail
FuelConsumptionUnit(options)
- Parameters:
- options
- {{unit:string,amount:number|string|undefined}} Options controlling the construction of this instance
Method Detail
{number|undefined}
convert(to)
Return a new measurement instance that is converted to a new
measurement unit. Measurements can only be converted
to measurements of the same type.
- Parameters:
- {string} to
- The name of the units to convert to
- Returns:
- {number|undefined} the converted measurement or undefined if the requested units are for a different measurement type
<static>
{number|undefined}
FuelConsumptionUnit.convert(to, from, fuelConsumption)
Convert a FuelConsumption to another measure.
- Parameters:
- to
- {string} unit to convert to
- from
- {string} unit to convert from
- fuelConsumption
- {number} amount to be convert
- Returns:
- {number|undefined} the converted amount
{Array.}
expand(measurementsystem, units)
Expand the current measurement such that any fractions of the current unit
are represented in terms of smaller units in the same system instead of fractions
of the current unit. For example, "6.25 feet" may be represented as
"6 feet 4 inches" instead. The return value is an array of measurements which
are progressively smaller until the smallest unit in the system is reached
or until there is a whole number of any unit along the way.
- Parameters:
- {string=} measurementsystem
- system to use (uscustomary|imperial|metric), or undefined if the system can be inferred from the current measure
- {Object=} units
- mapping from the measurement system to the units to use for this scaling. If this is not defined, this measurement type will use the set of units that it knows about for the given measurement system
- Returns:
- {Array.
} an array of new measurements in order from the current units to the smallest units in the system which together are the same measurement as this one
{string}
getMeasure()
Return the type of this measurement. Examples are "mass",
"length", "speed", etc. Measurements can only be converted
to measurements of the same type.
The type of the units is determined automatically from the units. For example, the unit "grams" is type "mass". Use the static call Measurement.getAvailableUnits to find out what units this version of ilib supports.
- Returns:
- {string} the name of the type of this measurement
{Measurement}
newUnit(params)
Return a new instance of this type of measurement.
- Parameters:
- {Object} params
- parameters to the constructor
- Returns:
- {Measurement} a measurement subclass instance
{Measurement}
scale(measurementsystem, units)
Scale the measurement unit to an acceptable level. The scaling
happens so that the integer part of the amount is as small as
possible without being below zero. This will result in the
largest units that can represent this measurement without
fractions. Measurements can only be scaled to other measurements
of the same type.
- Parameters:
- {string=} measurementsystem
- system to use (uscustomary|imperial|metric), or undefined if the system can be inferred from the current measure
- {Object=} units
- mapping from the measurement system to the units to use for this scaling. If this is not defined, this measurement type will use the set of units that it knows about for the given measurement system
- Returns:
- {Measurement} a new instance that is scaled to the right level