function SVGPathGenerator(path) {
    if (!(this instanceof SVGPathGenerator)) {
        return new SVGPathGenerator(path);
    }

    this.currentPath = (path || '') + ' ';
    this.isRelative = false;
}

export default SVGPathGenerator;

SVGPathGenerator.prototype.toString = function() {
    return this.end();
};


SVGPathGenerator.prototype.moveTo = function() {
    this._appendData('M', arguments);
    return this;
};


SVGPathGenerator.prototype.close = SVGPathGenerator.prototype.closePath = function() {
    this._appendData('Z', []);
    return this;
};

SVGPathGenerator.prototype.lineTo = function() {
    this._appendData('L', arguments);
    return this;
};

SVGPathGenerator.prototype.horizontalLineTo = function(x) {
    this._appendData('H', [x]);
    return this;
};

SVGPathGenerator.prototype.verticalLineTo = function(y) {
    this._appendData('V', [y]);
    return this;
};

SVGPathGenerator.prototype.curveTo = function() {
    this._appendData('C', arguments);
    return this;
};

SVGPathGenerator.prototype.smoothCurveTo = function() {
    this._appendData('S', arguments);
    return this;
};

SVGPathGenerator.prototype.bezierCurveTo = function() {
    this._appendData('Q', arguments);
    return this;
};

SVGPathGenerator.prototype.smoothBezierCurveTo = function() {
    this._appendData('T', arguments);
    return this;
};

SVGPathGenerator.prototype.ellipticalArc = function() {
    this._appendData('A', arguments);
    return this;
};

SVGPathGenerator.prototype.relative = function() {
    this.isRelative = true;
    return this;
};

SVGPathGenerator.prototype.end = function() {
    return this.currentPath.trim();
};


SVGPathGenerator.prototype._appendData = function(symbol, args) {

    args = Array.prototype.slice.call(args);

    if(this.isRelative) {
        symbol = symbol.toLowerCase();
        this.isRelative = false;
    }

    this.currentPath += symbol + ' ' + args.join(' ') + ' ';
};