1
0
Fork 0
freesewing/lib/pattern.ts

38 lines
823 B
TypeScript
Raw Normal View History

2018-07-10 19:29:09 +02:00
import { PatternConfig, PatternOption } from './types'
import Part from './part'
import Option from './option'
2018-07-10 12:20:53 +00:00
export default class Pattern {
config: PatternConfig;
2018-07-10 19:29:09 +02:00
parts: {[propName: string]: Part};
options: {[propName: string]: Option};
2018-07-10 12:20:53 +00:00
constructor(config: PatternConfig) {
this.config = config;
2018-07-10 19:29:09 +02:00
this.parts = {};
for (let id of config.parts) {
this.parts[id] = new Part(id);
}
this.options = {};
for (let conf of config.options) {
this.options[conf.id] = new Option(conf);
}
2018-07-10 12:20:53 +00:00
return this;
}
2018-07-10 19:29:09 +02:00
draft(config: object): void {
throw Error('You have to implement the draft() method in your Pattern instance.');
}
2018-07-11 12:45:02 +00:00
getOption(id: string | number): any {
return this.options[id].val;
}
o(id: string | number): any {
return this.getOption(id);
}
2018-07-10 12:20:53 +00:00
}