1
0
Fork 0
freesewing/lib/attributes.ts
2018-07-19 09:29:25 +00:00

30 lines
590 B
TypeScript

export class Attributes {
list: any = {};
/** Adds an attribute */
add(name: string, value: string): Attributes {
if(typeof this.list[name] === 'undefined') {
this.list[name] = [];
}
this.list[name].push(value);
return this;
}
/** Retrieves an attribute */
get(name: string): string {
return this.list[name].join(' ');
}
/** 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(' ')}"`;
}
return svg;
}
}