UNPKG

course-renderer

Version:

Manages CA School Courses file system storage and HTML conversion

102 lines (78 loc) 1.89 kB
export default class Token { type?: string content?: string code?: string[] children?: Token[] answer?: string param?: string[] choices?: string[] chapter: string id?: string readonly?: boolean caption?: string initialization?: string files?: string[] choiceType: string constructor(type: string) { this.type = type if (type === 'REPL') { this.setReadonly() } } setType(type: string) { this.type = type } addChild(token: Token) { if (!this.children) this.children = [] this.children.push(token) } setContent(content: string) { this.content = content } setAnswer(answer: string) { this.answer = answer } setChapter(chapter: string) { this.chapter = chapter } setReadonly(readonly: boolean = false) { this.readonly = readonly } setCaption(caption: string) { this.caption = caption } setId(id: string) { this.id = id } setInitialization(initialization: string) { this.initialization = initialization } addCode(code: string) { if (!this.code) this.code = []; this.code.push(code); } addParam(param: string) { if (!this.param) this.param = []; this.param.push(param); } addFile(file: string) { if (!this.files) this.files = []; this.files.push(file); } addChoice(choice: string) { if (!this.choices) this.choices = [] this.choices.push(choice) } getFiles() { return this.files ? this.files : []; } getCodes() { return this.code ? this.code : []; } setChoiceType(choiceType: string) { this.choiceType = choiceType; } getChoiceType() { return this.choiceType; } }