Skip to content

Commit

Permalink
fix: add docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
star0202 committed Jun 27, 2024
1 parent 97f6d7a commit 0b5b89e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export default class Comcigan {

private readonly dataManager = new DataManager(this.rest)

/** 학교를 검색합니다. */
async searchSchools(schoolName: string): Promise<School[]> {
const { mainRoute, searchRoute } = await this.dataManager.getData()
const res = await this.rest.get(
Expand All @@ -34,6 +35,7 @@ export default class Comcigan {
}))
}

/** 학교 코드를 이용해 학교 시간표를 불러옵니다. */
async getRawTimetable(schoolCode: number): Promise<Timetable[][][][]> {
const { mainRoute, timetableRoute, teacherCode, dayCode, subjectCode } =
await this.dataManager.getData()
Expand Down Expand Up @@ -62,6 +64,7 @@ export default class Comcigan {
)
}

/** 학교 코드를 이용해 학교 시간표를 불러오고, `TimetableManager`로 변환해 사용할 수 있는 형태로 제공합니다. */
async getTimetable(schoolCode: number) {
return new TimetableManager(await this.getRawTimetable(schoolCode))
}
Expand Down
1 change: 1 addition & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const RegExes = {
WhiteSpace: /\0+$/,
}

/** 요일 */
export enum Weekday {
Monday = 1,
Tuesday,
Expand Down
6 changes: 6 additions & 0 deletions src/models/Timetable.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,29 @@
export interface Timetable {
/** 과목 */
subject: string
/** 교사 */
teacher: string
}

export class TimetableManager {
constructor(private readonly timetables: Timetable[][][][]) {}

/** 특정 학년의 시간표를 가져옵니다. */
getByGrade(grade: number) {
return this.timetables[grade - 1]
}

/** 특정 반의 시간표를 가져옵니다. */
getByClass(grade: number, cls: number) {
return this.timetables[grade - 1][cls - 1]
}

/** 특정 반의 특정 요일 시간표를 가져옵니다. */
getByDay(grade: number, cls: number, day: number) {
return this.timetables[grade - 1][cls - 1][day - 1]
}

/** 특정 반의 특정 요일의 특정 교시 시간표를 가져옵니다. */
getByPeriod(grade: number, cls: number, day: number, period: number) {
return this.timetables[grade - 1][cls - 1][day - 1][period - 1]
}
Expand Down

0 comments on commit 0b5b89e

Please sign in to comment.