forked from LeetCode-OpenSource/vscode-leetcode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLeetCodeNode.ts
71 lines (55 loc) · 1.6 KB
/
LeetCodeNode.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// Copyright (c) jdneo. All rights reserved.
// Licensed under the MIT license.
import { Command, Uri } from "vscode";
import { IProblem, ProblemState } from "../shared";
export class LeetCodeNode {
constructor(private data: IProblem, private isProblemNode: boolean = true) { }
public get locked(): boolean {
return this.data.locked;
}
public get name(): string {
return this.data.name;
}
public get state(): ProblemState {
return this.data.state;
}
public get id(): string {
return this.data.id;
}
public get passRate(): string {
return this.data.passRate;
}
public get difficulty(): string {
return this.data.difficulty;
}
public get tags(): string[] {
return this.data.tags;
}
public get companies(): string[] {
return this.data.companies;
}
public get isFavorite(): boolean {
return this.data.isFavorite;
}
public get isProblem(): boolean {
return this.isProblemNode;
}
public get previewCommand(): Command {
return {
title: "Preview Problem",
command: "leetcode.previewProblem",
arguments: [this],
};
}
public get acceptanceRate(): number {
return Number(this.passRate.slice(0, -1).trim());
}
public get uri(): Uri {
return Uri.from({
scheme: "leetcode",
authority: this.isProblem ? "problems" : "tree-node",
path: `/${this.id}`, // path must begin with slash /
query: `difficulty=${this.difficulty}`,
});
}
}