All files / src/objects number_range.ts

96.72% Statements 59/61
90.24% Branches 37/41
100% Functions 7/7
96.72% Lines 59/61

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 50 51 52 53 54 55 56 57 58 59 60 611x 1x 1x 1x 1x 1x 1x 1x 1x 1x 7x 7x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 2x 2x 2x 1x 1x 5x 3x 3x 2x 2x 2x 5x     2x 5x 5x 5x 5x 5x 5x 5x 5x 5x 1x 1x 1x 1x 1x 1x
import {AbstractObject} from "./_abstract_object";
 
export class NumberRange extends AbstractObject {
  private parsedXML: {
    description?: string,
    domain?: string,
    percentage?: number,
  } | undefined;
 
  public getType(): string {
    return "NROB";
  }
 
  public getAllowedNaming() {
    return {
      maxLength: 10,
      allowNamespace: true,
    };
  }
 
  public getDomain(): string | undefined {
    this.parse();
    return this.parsedXML?.domain;
  }
 
  public getPercentage(): number | undefined {
    this.parse();
    return this.parsedXML?.percentage;
  }
 
  public setDirty(): void {
    this.parsedXML = undefined;
    super.setDirty();
  }
 
  public parse() {
    if (this.parsedXML) {
      return {updated: false, runtime: 0};
    }
    const start = Date.now();
    this.parsedXML = {};
    const parsed = super.parseRaw2();
    if (parsed === undefined) {
      return {updated: false, runtime: 0};
    }
 
    const text = parsed.abapGit?.["asx:abap"]?.["asx:values"]?.TEXT;
    this.parsedXML.description = text?.TXT;
    const attributes = parsed.abapGit?.["asx:abap"]?.["asx:values"]?.ATTRIBUTES;
    this.parsedXML.domain = attributes?.DOMLEN;
    this.parsedXML.percentage = parseFloat(attributes?.PERCENTAGE || "");
 
    const end = Date.now();
    return {updated: true, runtime: end - start};
  }
 
  public getDescription(): string | undefined {
    this.parse();
    return this.parsedXML?.description;
  }
}