diff options
| author | Furkan Sahin <furkan-dev@proton.me> | 2021-11-05 09:27:35 -0500 |
|---|---|---|
| committer | Furkan Sahin <furkan-dev@proton.me> | 2021-11-05 09:27:35 -0500 |
| commit | 85380b4b60bf74507a01957b29bd6e3808e216db (patch) | |
| tree | a43784660fdc29e5b95df3e358cf722eec2b092b /src/models/Lab.ts | |
| parent | ffef3a6be19d1139b6378c8119d444082dd0cbac (diff) | |
| parent | 29fc563863f561cdc707485289c5580b4397a580 (diff) | |
Merge pull request #10 from cobraguy/rewrite
Update to Svelte app
Diffstat (limited to 'src/models/Lab.ts')
| -rw-r--r-- | src/models/Lab.ts | 59 |
1 files changed, 43 insertions, 16 deletions
diff --git a/src/models/Lab.ts b/src/models/Lab.ts index a6972ef..d23cffb 100644 --- a/src/models/Lab.ts +++ b/src/models/Lab.ts @@ -1,23 +1,50 @@ -import EventInfo from '@/models/EventInfo'; +import EventInfo from "./EventInfo"; + +interface LabSerializeInfo { + course: number, + section: number, + event: { + days: string, + start: number, + end: number + }, + building: string, + room: string +} export default class Lab { - course: number; + id: number; + course: number; + section: number; + event: EventInfo; + building: string; + room: string; - section: number; + constructor(course: number | string, section: number | string, event: EventInfo, building = "", room = "") { + if(typeof course === "string") { + course = parseInt(course, 10); + } + if(typeof section === "string") { + section = parseInt(section, 10); + } - event: EventInfo; + this.id = parseInt(`${course}${section}`, 10); + this.course = course; + this.section = section; + this.event = event; + this.building = building; + this.room = room; + } - constructor(course = 0, section = 0, event = new EventInfo()) { - this.course = course; - this.section = section; - this.event = event; - } + static fromJSON({course, section, event, building, room}: LabSerializeInfo) { + return new Lab(course, section, EventInfo.fromJSON(event), building, room); + } - get id() { - return `${this.course}-${this.section}`; - } + get time() { + return this.event.info; + } - get fullInfo() { - return `${this.id} ${this.event.info}`; - } -} + get location() { + return `${this.building}-${this.room}`; + } +}
\ No newline at end of file |
