Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

not_filter.js 1.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // Copyright 2014 Mark Cavage, Inc. All rights reserved.
  2. // Copyright 2014 Patrick Mooney. All rights reserved.
  3. var util = require('util');
  4. var assert = require('assert-plus');
  5. var helpers = require('./helpers');
  6. ///--- API
  7. function NotFilter(options) {
  8. if (typeof (options) === 'object') {
  9. assert.object(options.filter, 'options.filter');
  10. } else {
  11. options = {};
  12. }
  13. this.filter = options.filter || {};
  14. var self = this;
  15. this.__defineGetter__('type', function () { return 'not'; });
  16. this.__defineGetter__('json', function () {
  17. return {
  18. type: 'Not',
  19. filter: self.filter
  20. };
  21. });
  22. }
  23. util.inherits(NotFilter, helpers.Filter);
  24. NotFilter.prototype.addFilter = function (filter) {
  25. assert.object(filter, 'filter');
  26. this.filter = filter;
  27. };
  28. NotFilter.prototype.toString = function () {
  29. return '(!' + this.filter.toString() + ')';
  30. };
  31. NotFilter.prototype.matches = function (target, strictAttrCase) {
  32. return !this.filter.matches(target, strictAttrCase);
  33. };
  34. ///--- Exports
  35. module.exports = NotFilter;