UNPKG

tcx-builder

Version:
54 lines (53 loc) 2.35 kB
"use strict"; 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 ActivityAttributes_1 = require("./ActivityAttributes"); var lodash_1 = require("lodash"); var Activity = /** @class */ (function (_super) { __extends(Activity, _super); function Activity(sport, options) { if (sport === void 0) { sport = 'Running'; } var _this = _super.call(this) || this; _this.attributes = new ActivityAttributes_1.ActivityAttributes(sport); _this.Id = options.Id; _this.Laps = options.Laps; _this.Notes = options.Notes; _this.Training = options.Training; _this.Creator = options.Creator; return _this; } Activity.prototype.toXml = function () { var xmlElement = ''; xmlElement += _common_1.BaseObject.buildXmlNode('Id', this.Id.toISOString()); if (!lodash_1.isNil(this.Laps) && this.Laps.length) { xmlElement += this.Laps .map(function (_activityLap) { return _common_1.BaseObject.buildXmlNode('Lap', _activityLap.toXml(), _activityLap.attributes); }) .join('\n'); } if (!lodash_1.isNil(this.Notes)) { xmlElement += _common_1.BaseObject.buildXmlNode('Notes', this.Notes); } if (!lodash_1.isNil(this.Training)) { xmlElement += _common_1.BaseObject.buildXmlNode('Training', this.Training.toXml(), this.Training.attributes); } if (!lodash_1.isNil(this.Creator)) { xmlElement += _common_1.BaseObject.buildXmlNode('Creator', this.Creator.toXml(), this.Creator.attributes); } return xmlElement; }; return Activity; }(_common_1.BaseObject)); exports.Activity = Activity;