Class QuantitySnak

class for the QuantitySnak

most used property of this type P1215 (apparent magnitude)

Hierarchy (view full)

Constructors

  • Parameters

    • snak: QuantitySnak

      the snak for this class in json format

    Returns QuantitySnak

    Throws

    if the upperBound is smaller than the amount or the lowerBound is bigger than the amount

    Example

    const snak = new QuantitySnak(json);
    

Properties

_amount: undefined | string = undefined
_lowerBound: undefined | string = undefined
_upperBound: undefined | string = undefined
datatype: string = 'quantity'
hash: undefined | string
property: `P${number}`
snaktype: SnakType
unit: undefined | string

Accessors

  • get amount(): undefined | number
  • Returns undefined | number

    the amount of the quantity

  • set amount(number): void
  • Parameters

    • number: undefined | number

      the number that the amount will be set to

    Returns void

  • get hasValue(): boolean
  • Returns boolean

    true if the snak has a value

  • get internalID(): string
  • create a unique id for the Snak

    Returns string

    the id

  • get lowerBound(): undefined | number
  • Returns undefined | number

    the lowerBound of the quantity

  • set lowerBound(number): void
  • Parameters

    • number: undefined | number

      the number that the lowerBound will be set to

    Returns void

  • get upperBound(): undefined | number
  • Returns undefined | number

    the upperBound of the quantity

  • set upperBound(number): void
  • Parameters

    • number: undefined | number

      the number that the upperBound will be set to

    Returns void

Methods

  • this function checks if two snaks are equal

    Parameters

    Returns boolean

    true if the snaks are equal

    Example

    if (snak.equals(other)) {
    // do something
    }
  • create a snak from some basic data

    Parameters

    • property: `P${number}`

      the property of the snak in 'P-form'

    • quantity: number

      amount of the quantity

    • Optional lowerBound: null | number

      lowerBound of the quantity

    • Optional upperBound: null | number

      upperBound of the quantity

    • Optional unit: `Q${number}`

      unit of the quantity

    Returns QuantitySnak

    a snak with the given properties

    Static

    Example

    const snak = QuantitySnak.fromNumbers('P1215', 1);
    

Generated using TypeDoc