Options
All
  • Public
  • Public/Protected
  • All
Menu

The class which converts Unitz objects to strings.

Hierarchy

  • Output

Implements

Index

Constructors

constructor

  • Creates a new instance of Output with an optional set of options to override the default values.

    Parameters

    • Optional input: OutputInput

      The options to apply to the new instance.

    Returns Output

Properties

delimiter

delimiter: string = ", "

The delimiter used to separate ranges.

format

format: OutputFormat = OutputFormat.GIVEN

The option that specifies how values are displayed.

fractionSpacer

fractionSpacer: string = "/"

The spacing used to separate the numerator and denominator of a fraction.

mixedSpacer

mixedSpacer: string = " "

The spacing used to seperate a mixed number from the fraction.

rangeSpacer

rangeSpacer: string = " - "

The spacing used between the minimum and maximum values in a range.

rateSpacer

rateSpacer: string = "/"

The spacing used to separate a unit and the rate unit.

repeatUnit

repeatUnit: boolean = false

Whether or not a unit should be displayed for the minimum and maximum of a range when they have the same group.

significant

significant: number = -1

An option used to restrict numbers from displaying large decimal numbers. When this value is set to -1 numbers are displayed fully. If the value is set to zero all numbers will be truncated to the whole version.

unit

unit: OutputUnit = OutputUnit.GIVEN

The option that specifies which units are chosen.

unitSpacer

unitSpacer: string = ""

The spacing used between the value and the unit.

Methods

extend

  • Returns an Output instance which matches the desired options. If no options are specified the reference to this instance is returned. If the options are already an instance of Output its returned. If options are specified a new instance is created with the options of this instance, and the given options applied with Output.set.

    Parameters

    Returns Output

    An instance of this class which matches the desired options.

group

  • group(value: number, unit: string, group: Group): string
  • Generates a unit string given the value, the current unit, and its group.

    Parameters

    • value: number

      The value to generate a unit for.

    • unit: string

      The unit to potentially use.

    • group: Group

      The group of the unit.

    Returns string

    The unit determined based on the options.

isFraction

  • isFraction(value: Value): boolean
  • Determines whether the value should be displayed as a fraction.

    Parameters

    • value: Value

      The value to look at.

    Returns boolean

    True if the value should be displayed as a fraction, otherwise false.

isLongUnit

  • isLongUnit(group: Group): boolean
  • Determines whether the long unit should be displayed.

    Parameters

    • group: Group

      The group of the unit.

    Returns boolean

    True if the short unit should be displayed, otherwise false.

isMixed

  • isMixed(value: Value): boolean
  • Determines whether the value should be displayed as a mixed fraction. This assumes Output.isFraction was already checked and returned true.

    Parameters

    • value: Value

      The value to look at.

    Returns boolean

    True if the value should be displayed as a mixed fraction, otherwise false.

isNumber

  • isNumber(value: Value): boolean
  • Determines whether the value should be displayed as a number.

    Parameters

    • value: Value

      The value to look at.

    Returns boolean

    True if the value should be displayed as a number, otherwise false.

isShortUnit

  • isShortUnit(group: Group): boolean
  • Determines whether the short unit should be displayed.

    Parameters

    • group: Group

      The group of the unit.

    Returns boolean

    True if the short unit should be displayed, otherwise false.

number

  • number(x: number): string
  • Converts the number to a string.

    Parameters

    • x: number

      The number to convert.

    Returns string

    The string representation of the input.

range

  • range(range: Range): string
  • Converts the range to a string.

    Parameters

    Returns string

    The string representation of the input.

ranges

  • Converts the list of ranges to a string. If a range is not valid it is skipped.

    Parameters

    • ranges: RangeList

      The list of ranges to convert.

    Returns string

    The string representation of the input.

set

  • Overrides values in this instance with ones specified in input.

    Parameters

    Returns this

    The reference to this instance.

units

  • units(value: Value): string
  • Generates a full unit string including the rate unit if it exists.

    Parameters

    • value: Value

      The value to generate a unit for.

    Returns string

    The units string representation.

value

  • value(value: Value, showUnit?: boolean): string
  • Converts the value to the string optionally showing or hiding the unit.

    Parameters

    • value: Value

      The value to convert.

    • Default value showUnit: boolean = true

      Whether or not the unit should be added to the string.

    Returns string

    The string representation of the input.

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc