\SassNumber
SassNumber class.
Provides operations and type testing for Sass numbers.
Units are of the passed value are converted the those of the class value
if it has units. e.g. 2cm + 20mm = 4cm while 2 + 20mm = 22mm.
Synopsis
class SassNumber
extends SassLiteral
{
- // constants
- const MATCH = '/^((?:-)?(?:\d*\.)?\d+)(([a-z%]+)(\s*[\*\/]\s*[a-z%]+)*)?/i';
- const VALUE = 1;
- const UNITS = 2;
- const PRECISION = 3;
- // members
- private static array $unitConversion = ;
- private static array $validUnits = ;
- private array $numeratorUnits = ;
- private array $denominatorUnits = ;
- public boolean $inExpression = true;
- // methods
- public SassNumber __construct()
- public mixed op_plus()
- public SassNumber op_unary_plus()
- public mixed op_minus()
- public SassNumber op_unary_minus()
- public void op_unary_concat()
- public mixed op_times()
- public mixed op_div()
- public SassBoolean op_eq()
- public SassBoolean op_gt()
- public SassBoolean op_gte()
- public SassBoolean op_lt()
- public SassBoolean op_lte()
- public mixed op_modulo()
- private SassNumber convert()
- public SassNumber coerce()
- private float coercionFactor()
- private boolean areConvertable()
- private array removeCommonUnits()
- public boolean isUnitless()
- public boolean hasUnits()
- public boolean hasLegalUnits()
- public string unitString()
- public string getUnits()
- public string getDenominatorUnits()
- public string getNumeratorUnits()
- public boolean isComparableTo()
- public boolean isInt()
- public float getValue()
- public integer toInt()
- public string toString()
- public static mixed isa()
- // Inherited methods from SassLiteral
- public SassLiteral __construct()
- public mixed __get()
- public void __toString()
- public boolean toBoolean()
- public string getTypeOf()
- public mixed getValue()
- public void getChildren()
- public void addChild()
- public sassString op_plus()
- public sassString op_minus()
- public sassString op_times()
- public sassString op_div()
- public SassLiteral op_modulo()
- public string op_bw_and()
- public string op_bw_or()
- public string op_bw_xor()
- public string op_bw_not()
- public string op_shiftl()
- public string op_shiftr()
- public SassLiteral op_and()
- public SassLiteral op_or()
- public void op_assign()
- public SassBoolean op_xor()
- public SassBoolean op_not()
- public SassBoolean op_gt()
- public SassBoolean op_gte()
- public SassBoolean op_lt()
- public SassBoolean op_lte()
- public SassBoolean op_eq()
- public SassBoolean op_neq()
- public sassString op_concat()
- public sassString op_comma()
- public static void assertType()
- public static void assertInRange()
- public abstract string toString()
- public void render()
- public static mixed isa()
Hierarchy
Extends
Constants
Name | Value |
---|---|
MATCH | '/^((?:-)?(?:\d*\.)?\d+)(([a-z%]+)(\s*[\*\/]\s*[a-z%]+)*)?/i' |
VALUE | 1 |
UNITS | 2 |
PRECISION | 3 |
Members
private
- $denominatorUnits — array
- $numeratorUnits — array
- $unitConversion — array
- $validUnits
public
- $inExpression — boolean
- $typeOf — array
- $value — mixed
Methods
private
- areConvertable() — Returns a value indicating if all the units are capable of being converted
- coercionFactor() — Calculates the corecion factor to apply to the value
- convert() — Converts values and units.
- removeCommonUnits() — Removes common units from each set.
public
- __construct() — class constructor.
- coerce() — Returns the value of this number converted to other units.
- getDenominatorUnits() — Returns the denominator units of this number.
- getNumeratorUnits() — Returns the numerator units of this number.
- getUnits() — Returns the units of this number.
- getValue() — Returns the value of this number.
- hasLegalUnits() — Returns a value indicating if this number has units that can be represented in CSS.
- hasUnits() — Returns a value indicating if this number has units.
- isComparableTo() — Returns a value indicating if this number can be compared to other.
- isInt() — Returns a value indicating if this number is an integer.
- isUnitless() — Returns a value indicating if this number is unitless.
- isa() — Returns a value indicating if a token of this type can be matched at the start of the subject string.
- op_div() — Divides this value by the value of other
- op_eq() — The SassScript == operation.
- op_gt() — The SassScript > operation.
- op_gte() — The SassScript >= operation.
- op_lt() — The SassScript < operation.
- op_lte() — The SassScript <= operation.
- op_minus() — Subtracts the value of other from this value
- op_modulo() — Takes the modulus (remainder) of this value divided by the value of other
- op_plus() — Adds the value of other to the value of this
- op_times() — Multiplies this value by the value of other
- op_unary_concat()
- op_unary_minus() — Unary - operator
- op_unary_plus() — Unary + operator
- toInt() — Returns the integer value.
- toString() — Converts the number to a string with it's units if any.
- unitString() — Returns a string representation of the units.
Inherited from SassLiteral
public
- __get() — Getter.
- __toString()
- addChild() — Adds a child object to this.
- assertInRange() — Asserts that the value of a literal is within the expected range
- assertType() — Asserts that the literal is the expected type
- getChildren()
- getTypeOf() — Returns the type of this
- getValue() — Returns the value of this
- isa() — Returns a value indicating if a token of this type can be matched at the start of the subject string.
- op_and() — The SassScript and operation.
- op_assign()
- op_bw_and() — Bitwise AND the value of other and this value
- op_bw_not() — Bitwise NOT the value of other and the value of this
- op_bw_or() — Bitwise OR the value of other and this value
- op_bw_xor() — Bitwise XOR the value of other and the value of this
- op_comma() — SassScript ',' operation.
- op_concat() — The SassScript default operation (e.g. $a $b, "foo" "bar").
- op_div() — SassScript '/' operation.
- op_eq() — The SassScript == operation.
- op_gt() — The SassScript > operation.
- op_gte() — The SassScript >= operation.
- op_lt() — The SassScript < operation.
- op_lte() — The SassScript <= operation.
- op_minus() — SassScript '-' operation.
- op_modulo() — SassScript '%' operation.
- op_neq() — The SassScript != operation.
- op_not() — The SassScript not operation.
- op_or() — The SassScript or operation.
- op_plus() — SassScript '+' operation.
- op_shiftl() — Shifts the value of this left by the number of bits given in value
- op_shiftr() — Shifts the value of this right by the number of bits given in value
- op_times() — SassScript '*' operation.
- op_xor() — The SassScript xor operation.
- render()
- toBoolean() — Returns the boolean representation of the value of this
- toString() — Returns a string representation of the value.