All files / src/objects maintenance_and_transport_object.ts

23.53% Statements 4/17
0% Branches 0/6
28.57% Functions 2/7
23.53% Lines 4/17

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 501x   1x 1x               1x                                                                            
import {AbstractObject} from "./_abstract_object";
 
export class MaintenanceAndTransportObject extends AbstractObject {
  private area: string | undefined = undefined;
 
  public setDirty() {
    super.setDirty();
    this.area = undefined;
  }
 
  public getType(): string {
    return "TOBJ";
  }
 
  public getDescription(): string | undefined {
    // todo
    return undefined;
  }
 
  public getAllowedNaming() {
    return {
      maxLength: 31,
      allowNamespace: true,
    };
  }
 
  public getArea(): string | undefined {
    if (this.area === undefined) {
      this.parseXML();
    }
    return this.area;
  }
 
////////////
 
  private parseXML() {
    if (this.getFiles().length === 0) {
      return;
    }
 
    const xml = this.getFiles()[0].getRaw();
 
    const result = xml.match(/<AREA>([\w/]+)<\/AREA>/);
    if (result) {
      this.area = result[1];
    }
  }
 
}