unitsnet-js
Version:
A better way to hold unit variables and easily convert to the destination unit
195 lines (194 loc) • 7.36 kB
TypeScript
import { BaseUnit, ToStringOptions } from "../base-unit";
/** API DTO represents a Ratio */
export interface RatioDto {
/** The value of the Ratio */
value: number;
/** The specific unit that the Ratio value is representing */
unit: RatioUnits;
}
/** RatioUnits enumeration */
export declare enum RatioUnits {
/** */
DecimalFractions = "DecimalFraction",
/** */
Percent = "Percent",
/** */
PartsPerThousand = "PartPerThousand",
/** */
PartsPerMillion = "PartPerMillion",
/** */
PartsPerBillion = "PartPerBillion",
/** */
PartsPerTrillion = "PartPerTrillion"
}
/** In mathematics, a ratio is a relationship between two numbers of the same kind (e.g., objects, persons, students, spoonfuls, units of whatever identical dimension), usually expressed as "a to b" or a:b, sometimes expressed arithmetically as a dimensionless quotient of the two that explicitly indicates how many times the first number contains the second (not necessarily an integer). */
export declare class Ratio extends BaseUnit {
protected value: number;
private decimalfractionsLazy;
private percentLazy;
private partsperthousandLazy;
private partspermillionLazy;
private partsperbillionLazy;
private partspertrillionLazy;
/**
* Create a new Ratio.
* @param value The value.
* @param fromUnit The ‘Ratio’ unit to create from.
* The default unit is DecimalFractions
*/
constructor(value: number, fromUnit?: RatioUnits);
/**
* The base value of Ratio is DecimalFractions.
* This accessor used when needs a value for calculations and it's better to use directly the base value
*/
get BaseValue(): number;
/** Gets the default unit used when creating instances of the unit or its DTO */
protected get baseUnit(): RatioUnits.DecimalFractions;
/** */
get DecimalFractions(): number;
/** */
get Percent(): number;
/** */
get PartsPerThousand(): number;
/** */
get PartsPerMillion(): number;
/** */
get PartsPerBillion(): number;
/** */
get PartsPerTrillion(): number;
/**
* Create a new Ratio instance from a DecimalFractions
*
* @param value The unit as DecimalFractions to create a new Ratio from.
* @returns The new Ratio instance.
*/
static FromDecimalFractions(value: number): Ratio;
/**
* Create a new Ratio instance from a Percent
*
* @param value The unit as Percent to create a new Ratio from.
* @returns The new Ratio instance.
*/
static FromPercent(value: number): Ratio;
/**
* Create a new Ratio instance from a PartsPerThousand
*
* @param value The unit as PartsPerThousand to create a new Ratio from.
* @returns The new Ratio instance.
*/
static FromPartsPerThousand(value: number): Ratio;
/**
* Create a new Ratio instance from a PartsPerMillion
*
* @param value The unit as PartsPerMillion to create a new Ratio from.
* @returns The new Ratio instance.
*/
static FromPartsPerMillion(value: number): Ratio;
/**
* Create a new Ratio instance from a PartsPerBillion
*
* @param value The unit as PartsPerBillion to create a new Ratio from.
* @returns The new Ratio instance.
*/
static FromPartsPerBillion(value: number): Ratio;
/**
* Create a new Ratio instance from a PartsPerTrillion
*
* @param value The unit as PartsPerTrillion to create a new Ratio from.
* @returns The new Ratio instance.
*/
static FromPartsPerTrillion(value: number): Ratio;
/**
* Gets the base unit enumeration associated with Ratio
* @returns The unit enumeration that can be used to interact with this type
*/
protected static getUnitEnum(): typeof RatioUnits;
/**
* Gets the default unit used when creating instances of the unit or its DTO
* @returns The unit enumeration value used as a default parameter in constructor and DTO methods
*/
protected static getBaseUnit(): RatioUnits.DecimalFractions;
/**
* Create API DTO represent a Ratio unit.
* @param holdInUnit The specific Ratio unit to be used in the unit representation at the DTO
*/
toDto(holdInUnit?: RatioUnits): RatioDto;
/**
* Create a Ratio unit from an API DTO representation.
* @param dtoRatio The Ratio API DTO representation
*/
static FromDto(dtoRatio: RatioDto): Ratio;
/**
* Convert Ratio to a specific unit value.
* @param toUnit The specific unit to convert to
* @returns The value of the specific unit provided.
*/
convert(toUnit: RatioUnits): number;
private convertFromBase;
private convertToBase;
/**
* Format the Ratio to string.
* Note! the default format for Ratio is DecimalFractions.
* To specify the unit format set the 'unit' parameter.
* @param unit The unit to format the Ratio.
* @param options The ToString options, it also can be the number of fractional digits to keep that deprecated and moved to the options object. support in number will be dropped in the upcoming versions.
* @returns The string format of the Ratio.
*/
toString(unit?: RatioUnits, options?: number | ToStringOptions): string;
/**
* Get Ratio unit abbreviation.
* Note! the default abbreviation for Ratio is DecimalFractions.
* To specify the unit abbreviation set the 'unitAbbreviation' parameter.
* @param unitAbbreviation The unit abbreviation of the Ratio.
* @returns The abbreviation string of Ratio.
*/
getUnitAbbreviation(unitAbbreviation?: RatioUnits): string;
/**
* Check if the given Ratio are equals to the current Ratio.
* @param ratio The other Ratio.
* @returns True if the given Ratio are equal to the current Ratio.
*/
equals(ratio: Ratio): boolean;
/**
* Compare the given Ratio against the current Ratio.
* @param ratio The other Ratio.
* @returns 0 if they are equal, -1 if the current Ratio is less then other, 1 if the current Ratio is greater then other.
*/
compareTo(ratio: Ratio): number;
/**
* Add the given Ratio with the current Ratio.
* @param ratio The other Ratio.
* @returns A new Ratio instance with the results.
*/
add(ratio: Ratio): Ratio;
/**
* Subtract the given Ratio with the current Ratio.
* @param ratio The other Ratio.
* @returns A new Ratio instance with the results.
*/
subtract(ratio: Ratio): Ratio;
/**
* Multiply the given Ratio with the current Ratio.
* @param ratio The other Ratio.
* @returns A new Ratio instance with the results.
*/
multiply(ratio: Ratio): Ratio;
/**
* Divide the given Ratio with the current Ratio.
* @param ratio The other Ratio.
* @returns A new Ratio instance with the results.
*/
divide(ratio: Ratio): Ratio;
/**
* Modulo the given Ratio with the current Ratio.
* @param ratio The other Ratio.
* @returns A new Ratio instance with the results.
*/
modulo(ratio: Ratio): Ratio;
/**
* Pow the given Ratio with the current Ratio.
* @param ratio The other Ratio.
* @returns A new Ratio instance with the results.
*/
pow(ratio: Ratio): Ratio;
}