Options
All
  • Public
  • Public/Protected
  • All
Menu

A unit and its aliases as well as their plurality.

A group is relative to a base group or is a base group itself. As unit aliases are added to the group it determines the appropriate plural and singular long and short versions given the unit aliases in this group.

Hierarchy

  • Group

Index

Constructors

constructor

  • Creates a new instance of Group given a definition and the parent class.

    Parameters

    • definition: GroupDefinition

      The definition of the group.

    • parent: Class

      The class which contains this group.

    Returns Group

Properties

baseScale

baseScale: number = 1

The scale of this group relative to the base group. This is used for conversions of values with the same base group.

baseUnit

baseUnit: string

The unit of the base group. The base group is typically the smallest value and is also where the baseUnit matches unit.

classScale

classScale: number = 0

The scale of this group relative to the first base group added to the class. This is used to compare numbers of the same class across all bases.

common

common: boolean

Whether this group is considered common. A common group is one a developer has decided the user will be familiar with and would be okay seeing values in this unit.

denominators

denominators: number[]

The list of valid denominators for this group. Values when converted to fractions look at this list to ensure that fractions are not produced that are not user friendly. For example, no one would say 5/23 a meter.

dynamic

dynamic: boolean = false

Whether this group was dynamically created by user input having units not mapped to groups by the developer.

parent

parent: Class

The class this group belongs to.

pluralLong

pluralLong: string

The longest unit in this group that is used for plural values.

pluralShort

pluralShort: string

The longest unit in this group that is used for plural values.

preferredUnit

preferredUnit: string

The unit the developer prefers for their users.

see

Base.preferred

relativeScale

relativeScale: number

This defines how to calculate the scale of the group by multiplying it by the group of relativeUnit.

relativeUnit

relativeUnit: string

The unit this group is relative to.

singularLong

singularLong: string

The longest unit in this group that is used for singular values.

singularShort

singularShort: string

The shortest unit in this group that is used for singular values.

system

system: System

The System this group belongs in. One of System.METRIC, System.US, or System.ANY.

unit

unit: string

The main unit for this group. This is the preferred unit if one is not specified in the definition.

units

A map of all valid units and whether they are singular, plural, or either.

Accessors

isBase

isBase:

True if this group is a base group, otherwise false.

Methods

addDenominator

  • addDenominator(denominators: Numbers): this
  • Adds a denominator or array of denominators to this group.

    Parameters

    • denominators: Numbers

      A denominator or an array of denominators to add.

    Returns this

    The reference to this instance.

addUnits

matches

  • matches(transform: Transform, reverse: boolean, callback: function): void
  • Invokes a callback for each group in the parent class that are visible based on the given transform relative to this group.

    see

    Transform.isVisibleGroup

    Parameters

    • transform: Transform

      The transform which decides what groups are visible.

    • reverse: boolean

      If the groups of the class should be iterated in reverse.

    • callback: function

      A function to invoke with all visible groups found and the index of that group in the set of visible groups. If false is returned by the function iteration of visible groups ceases.

        • (group: Group, index: number): any
        • Parameters

          • group: Group

            The current visible group.

          • index: number

            The index of the current visible group.

          Returns any

    Returns void

removeUnits

  • removeUnits(units: string[]): this
  • Removes the given unit aliases from this group and the parent class.

    see

    Class.removeGroupUnit

    Parameters

    • units: string[]

      The array of unit aliases to remove.

    Returns this

    The reference to this instance.

setCommon

  • setCommon(common?: boolean): this
  • Sets the common flag of this group.

    see

    Group.common

    Parameters

    • Default value common: boolean = true

      Whether this group is common or not.

    Returns this

    The reference to this instance.

setDenominators

  • setDenominators(denominators: number[]): this
  • Sets the denominators of this group.

    see

    Group.denominators

    Parameters

    • denominators: number[]

      The new denominators for this group.

    Returns this

    The reference to this instance.

setDynamic

  • setDynamic(dynamic?: boolean): this
  • Sets the dynamic flag of this group.

    Parameters

    • Default value dynamic: boolean = true

      Whether this group is dynamic or not.

    Returns this

    The reference to this instance.

setPreferred

  • setPreferred(unit: string): this
  • Sets the preferred unit of this group.

    see

    Group.preferredUnit

    Parameters

    • unit: string

      The preferred unit of this group.

    Returns this

    The reference to this instance.

updateUnits

  • updateUnits(): this
  • Updates the singular and plural long and short form units for this group.

    Returns this

    The reference to this instance.

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