import { IRssResult, RssResult } from './rss-result';

export interface IRssEntry {
    filename: string;
    result: Record<string, IRssResult>;
}

export class RssEntry implements IRssEntry {
    readonly filename: string;
    readonly result: Record<string, RssResult>;

    constructor(entry: IRssEntry) {
        this.filename = entry.filename;

        const mappedResult: Record<string, RssResult> = {};
        for (const key of Object.keys(entry.result)) {
            const newKey = key.replace(new RegExp('_', 'g'), ' ');
            mappedResult[newKey] = new RssResult(entry.result[key], key);
        }
        this.result = mappedResult;
    }
}
