Sha256: 06b5c0b7b5850a16c5029ab08ede5fc5667e02a78fc47fbdf04faa90ad49f38f

Contents?: true

Size: 836 Bytes

Versions: 8

Compression:

Stored size: 836 Bytes

Contents

(function (tree) {

tree.Operation = function (op, operands) {
    this.op = op.trim();
    this.operands = operands;
};
tree.Operation.prototype.eval = function (env) {
    var a = this.operands[0].eval(env),
        b = this.operands[1].eval(env),
        temp;

    if (a instanceof tree.Dimension && b instanceof tree.Color) {
        if (this.op === '*' || this.op === '+') {
            temp = b, b = a, a = temp;
        } else {
            throw { name: "OperationError",
                    message: "Can't substract or divide a color from a number" };
        }
    }
    return a.operate(this.op, b);
};

tree.operate = function (op, a, b) {
    switch (op) {
        case '+': return a + b;
        case '-': return a - b;
        case '*': return a * b;
        case '/': return a / b;
    }
};

})(require('less/tree'));

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
less-2.0.7 lib/less/js/lib/less/tree/operation.js
less-2.0.6 lib/less/js/lib/less/tree/operation.js
less-2.0.5 lib/less/js/lib/less/tree/operation.js
less-2.0.4 lib/less/js/lib/less/tree/operation.js
less-2.0.3 lib/less/js/lib/less/tree/operation.js
less-2.0.2 lib/less/js/lib/less/tree/operation.js
less-2.0.1 lib/less/js/lib/less/tree/operation.js
less-2.0.0 lib/less/js/lib/less/tree/operation.js