smartinteract/ts/smartinteract.classes.answerbucket.ts

34 lines
751 B
TypeScript
Raw Normal View History

2020-02-02 13:45:59 +00:00
import * as plugins from './smartinteract.plugins';
import { IAnswerObject } from './smartinteract.classes.smartinteract';
/**
* class AnswerBucket holds answers
*/
export class AnswerBucket {
2020-02-02 18:05:50 +00:00
private answerMap = new plugins.lik.Objectmap<IAnswerObject>();
2020-02-02 13:45:59 +00:00
/**
* add an answer to the bucket
*/
2020-02-02 18:05:50 +00:00
public addAnswer(answerArg: IAnswerObject) {
2020-02-02 13:45:59 +00:00
this.answerMap.add(answerArg);
}
/**
* gets an answer for a specific name
*/
2020-02-02 18:05:50 +00:00
public getAnswerFor(nameArg: string) {
const answer = this.answerMap.find(answerArg => {
2020-02-02 13:45:59 +00:00
return answerArg.name === nameArg;
});
return answer ? answer.value : null;
}
/**
* gets all answers as array
*/
2020-02-02 18:05:50 +00:00
public getAllAnswers() {
2020-02-02 13:45:59 +00:00
return this.answerMap.getArray();
}
}