1
0
Fork 0
freesewing/lib/attributes.ts

31 lines
590 B
TypeScript
Raw Normal View History

2018-07-14 16:04:39 +00:00
export class Attributes {
list: any = {};
2018-07-14 16:04:39 +00:00
/** Adds an attribute */
add(name: string, value: string): Attributes {
if(typeof this.list[name] === 'undefined') {
this.list[name] = [];
}
this.list[name].push(value);
2018-07-14 16:04:39 +00:00
return this;
}
/** Retrieves an attribute */
get(name: string): string {
return this.list[name].join(' ');
}
2018-07-14 16:04:39 +00:00
/** Returns SVG code for attributes */
render(): string {
let svg = '';
for (let key in this.list) {
let attrs = this.list
svg += ` ${key}="${this.list[key].join(' ')}"`;
2018-07-14 16:04:39 +00:00
}
return svg;
}
}