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.

approx_filter.js 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 ApproximateFilter(options) {
  8. if (typeof (options) === 'object') {
  9. assert.string(options.attribute, 'options.attribute');
  10. assert.string(options.value, 'options.value');
  11. this.attribute = options.attribute;
  12. this.value = options.value;
  13. }
  14. var self = this;
  15. this.__defineGetter__('type', function () { return 'approx'; });
  16. this.__defineGetter__('json', function () {
  17. return {
  18. type: 'ApproximateMatch',
  19. attribute: self.attribute,
  20. value: self.value
  21. };
  22. });
  23. }
  24. util.inherits(ApproximateFilter, helpers.Filter);
  25. ApproximateFilter.prototype.toString = function () {
  26. return ('(' + helpers.escape(this.attribute) +
  27. '~=' + helpers.escape(this.value) + ')');
  28. };
  29. ApproximateFilter.prototype.matches = function () {
  30. // Consumers must implement this themselves
  31. throw new Error('approx match implementation missing');
  32. };
  33. ///--- Exports
  34. module.exports = ApproximateFilter;