carto/lib/mess/tree/comparison.js

38 lines
789 B
JavaScript

(function(tree) {
tree.Comparison = function Comparison(str) {
this.value = str;
};
tree.Comparison.prototype = {
toString: function() {
return {
'<': '&lt;',
'>': '&gt;',
'=': '=',
'!=': '!=',
'<=': '&lt;=',
'>=': '&gt;='}[this.value];
},
negate: function() {
return new tree.Comparison({
'<': '>=',
'<=': '>',
'>': '<=',
'>=': '<',
'=': '!=',
'!=': '='
}[this.value]);
},
eval: function() {
return this;
},
clone: function() {
var obj = Object.create(Object.getPrototypeOf(this));
obj.value = this.value;
return obj;
}
};
})(require('mess/tree'));