'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

var _attr = require('./attr');

var _attr2 = _interopRequireDefault(_attr);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

/**
 * Class FileAttr
 * Manage string with attributes encoded inside
 */
var FileAttr = function () {
  function FileAttr() {
    _classCallCheck(this, FileAttr);
  }

  _createClass(FileAttr, null, [{
    key: 'add',


    /**
     * Add attributes or modify them if they already exists
     * @param {String} str the string to modify
     * @param {Object} options object with attributes to add
     * @return {String} the string with the new attributes
     */
    value: function add(str, options) {
      var att = new _attr2.default(str);
      return att.insert(options);
    }

    /**
     * Remove attributes from string
     * @param {String} str the string to modify
     * @return {String} the string modified
     */

  }, {
    key: 'delete',
    value: function _delete(str) {
      return new _attr2.default(str).remove();
    }

    /**
     * @param  {String} str the string to get attributes from
     * @return {object|String} object (all the attributes) if the key is null, if not the value of the atrtibuts
     */

  }, {
    key: 'get',
    value: function get(str) {
      return new _attr2.default(str).val;
    }

    /**
     * @param  {String} str the string to test attributes from
     * @return {boolean} true if string has attr
     */

  }, {
    key: 'test',
    value: function test(str) {
      var att = new _attr2.default(str).val;
      return att.s != null;
    }
  }]);

  return FileAttr;
}();

exports.default = FileAttr;