smartinteract/ts/smartinteract.classes.answerbucket.ts
2020-02-02 13:45:59 +00:00

34 lines
720 B
TypeScript

import * as plugins from './smartinteract.plugins';
import { IAnswerObject } from './smartinteract.classes.smartinteract';
/**
* class AnswerBucket holds answers
*/
export class AnswerBucket {
answerMap = new plugins.lik.Objectmap<IAnswerObject>();
/**
* add an answer to the bucket
*/
addAnswer(answerArg: IAnswerObject) {
this.answerMap.add(answerArg);
}
/**
* gets an answer for a specific name
*/
getAnswerFor(nameArg: string) {
let answer = this.answerMap.find(answerArg => {
return answerArg.name === nameArg;
});
return answer ? answer.value : null;
}
/**
* gets all answers as array
*/
getAllAnswers() {
return this.answerMap.getArray();
}
}