NetNewsWire/Modules/Parser/Sources/OPMLParser/OPMLItem.swift

43 lines
879 B
Swift
Raw Normal View History

//
// OPMLItem.swift
//
//
// Created by Brent Simmons on 8/18/24.
//
import Foundation
import os
public class OPMLItem {
2024-08-27 04:27:30 +02:00
public let feedSpecifier: OPMLFeedSpecifier?
2024-08-27 04:27:30 +02:00
public let attributes: [String: String]?
public let titleFromAttributes: String?
public var items: [OPMLItem]?
public var isFolder: Bool {
2024-08-27 04:27:30 +02:00
(items?.count ?? 0) > 0
}
init(attributes: [String : String]?) {
2024-08-27 04:27:30 +02:00
self.titleFromAttributes = attributes?.opml_title ?? attributes?.opml_text
self.attributes = attributes
2024-08-27 04:27:30 +02:00
if let feedURL = attributes?.opml_xmlUrl {
self.feedSpecifier = OPMLFeedSpecifier(title: self.titleFromAttributes, feedDescription: attributes?.opml_description, homePageURL: attributes?.opml_htmlUrl, feedURL: feedURL)
2024-08-27 07:39:46 +02:00
} else {
self.feedSpecifier = nil
2024-08-27 04:27:30 +02:00
}
}
2024-08-27 05:03:58 +02:00
func add(_ item: OPMLItem) {
if items == nil {
items = [OPMLItem]()
}
items?.append(item)
}
}