export default class Guard {

    public test: string;
    public value: boolean;

    constructor(test: string, value?: boolean) {
      this.test = test;
      this.value = value;
    }

    public toString(): string {
        return `${this.test}?${this.value}`;
    }

    public static parseGuard(text: string): Guard {
        const [test, value] = text.split('?');
        if (value) {
            return new Guard(test, value === 'true')
        } else {
            return new Guard(test);
        }
    }

}

