ComparePoint
ComparePoint
A ComparePoint object compares numbers against each other. For example, is 6 greater than 3, or is 8 equal to 10.
Kind: global class
- ComparePoint
- new ComparePoint(operator, value)
- instance
- .operator
- .operator ⇒
string - .value
- .value ⇒
number - .isMatch(value) ⇒
boolean - .toJSON() ⇒
Object - .toString() ⇒
string
- static
- .isValidOperator(operator) ⇒
boolean
- .isValidOperator(operator) ⇒
new ComparePoint(operator, value)
Create a ComparePoint instance.
Throws:
CompareOperatorErroroperator is invalidRequiredArgumentErroroperator and value are requiredTypeErrorvalue must be numeric
| Param | Type | Description |
|---|---|---|
| operator | string | The comparison operator (One of =, !=, <>, <, >, <=, >=) |
| value | number | The value to compare to |
comparePoint.operator
Set the comparison operator.
Kind: instance property of ComparePoint
Throws:
- CompareOperatorError operator is invalid
| Param | Type | Description |
|---|---|---|
| operator | string | One of =, !=, <>, <, >, <=, >= |
comparePoint.operator ⇒ string
The comparison operator.
Kind: instance property of ComparePoint
comparePoint.value
Set the value.
Kind: instance property of ComparePoint
Throws:
TypeErrorvalue must be numeric
| Param | Type |
|---|---|
| value | number |
comparePoint.value ⇒ number
The comparison value
Kind: instance property of ComparePoint
comparePoint.isMatch(value) ⇒ boolean
Check whether value matches the compare point
Kind: instance method of ComparePoint
Returns: boolean - true if it is a match, false otherwise
| Param | Type | Description |
|---|---|---|
| value | number | The number to compare |
comparePoint.toJSON() ⇒ Object
Return an object for JSON serialising.
This is called automatically when JSON encoding the object.
Kind: instance method of ComparePoint
comparePoint.toString() ⇒ string
Return the String representation of the object.
This is called automatically when casting the object to a string.
Kind: instance method of ComparePoint
ComparePoint.isValidOperator(operator) ⇒ boolean
Check if the operator is valid.
Kind: static method of ComparePoint
Returns: boolean - true if the operator is valid, false otherwise
| Param | Type |
|---|---|
| operator | string |