tcx-builder
Version:
52 lines (51 loc) • 2.19 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 Workout = /** @class */ (function (_super) {
__extends(Workout, _super);
function Workout(attributes, options) {
var _this = _super.call(this) || this;
_this.attributes = attributes;
_this.Name = options.name;
_this.Step = options.step;
_this.ScheduledOn = options.scheduledOn;
_this.Notes = options.notes;
_this.Creator = options.creator;
return _this;
}
Workout.prototype.toXml = function () {
var xmlElement = '';
xmlElement += _common_1.BaseObject.buildXmlNode('Name', this.Name);
xmlElement += this.Step
.map(function (_step) { return _common_1.BaseObject.buildXmlNode('Step', _step.toXml(), _step.attributes); })
.join('\n');
if (!lodash_1.isNil(this.ScheduledOn) && this.ScheduledOn.length) {
xmlElement += this.ScheduledOn
.map(function (_date) { return _common_1.BaseObject.buildXmlNode('ScheduledOn', _date.toISOString()); })
.join('\n');
}
if (!lodash_1.isNil(this.Notes)) {
xmlElement += _common_1.BaseObject.buildXmlNode('Notes', this.Notes);
}
if (!lodash_1.isNil(this.Creator)) {
xmlElement += _common_1.BaseObject.buildXmlNode('Creator', this.Creator.toXml(), this.Creator.attributes);
}
return xmlElement;
};
return Workout;
}(_common_1.BaseObject));
exports.Workout = Workout;