tcx-builder
Version:
59 lines (58 loc) • 2.49 kB
JavaScript
;
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var _common_1 = require("../_common");
var lodash_1 = require("lodash");
var Course = /** @class */ (function (_super) {
__extends(Course, _super);
function Course(options) {
var _this = _super.call(this) || this;
_this.Name = options.name;
_this.Lap = options.lap;
_this.Track = options.track;
_this.Notes = options.notes;
_this.CoursePoint = options.coursePoint;
_this.Creator = options.creator;
return _this;
}
Course.prototype.toXml = function () {
var xmlElement = '';
xmlElement += _common_1.BaseObject.buildXmlNode('Name', this.Name);
if (!lodash_1.isNil(this.Lap) && this.Lap.length) {
xmlElement += this.Lap
.map(function (_lap) { return _common_1.BaseObject.buildXmlNode('Lap', _lap.toXml()); })
.join('\n');
}
if (!lodash_1.isNil(this.Track) && this.Track.length) {
xmlElement += this.Track
.map(function (_track) { return _common_1.BaseObject.buildXmlNode('Track', _track.toXml()); })
.join('\n');
}
if (!lodash_1.isNil(this.Notes)) {
xmlElement += _common_1.BaseObject.buildXmlNode('Notes', this.Notes);
}
if (!lodash_1.isNil(this.CoursePoint) && this.CoursePoint.length) {
xmlElement += this.CoursePoint
.map(function (_coursePoint) { return _common_1.BaseObject.buildXmlNode('CoursePoint', _coursePoint.toXml()); })
.join('\n');
}
if (!lodash_1.isNil(this.Creator)) {
xmlElement += _common_1.BaseObject.buildXmlNode('Creator', this.Creator.toXml(), this.Creator.attributes);
}
return xmlElement;
};
return Course;
}(_common_1.BaseObject));
exports.Course = Course;