NetNewsWire/Evergreen/FeedList/FeedListFeed.swift

54 lines
1.2 KiB
Swift
Raw Normal View History

2017-11-04 20:19:34 +01:00
//
// FeedListFeed.swift
// Evergreen
//
// Created by Brent Simmons on 11/4/17.
// Copyright © 2017 Ranchero Software. All rights reserved.
//
import Foundation
2017-11-04 22:53:21 +01:00
import RSCore
2017-11-04 20:19:34 +01:00
final class FeedListFeed: Hashable, DisplayNameProvider {
2017-11-04 20:19:34 +01:00
let name: String
let url: String
let homePageURL: String
let hashValue: Int
2017-11-04 22:53:21 +01:00
var nameForDisplay: String { // DisplayNameProvider
get {
return name
}
}
2017-11-04 20:19:34 +01:00
init(name: String, url: String, homePageURL: String) {
self.name = name
self.url = url
self.homePageURL = homePageURL
self.hashValue = url.hashValue
}
private struct Key {
static let name = "name"
static let editedName = "editedName" // Used in DefaultFeeds.plist
static let url = "url"
static let homePageURL = "homePageURL"
}
convenience init(dictionary: [String: String]) {
2017-11-04 20:19:34 +01:00
let name = (dictionary[Key.name] ?? dictionary[Key.editedName])!
let url = dictionary[Key.url]!
let homePageURL = dictionary[Key.homePageURL]!
self.init(name: name, url: url, homePageURL: homePageURL)
}
static func ==(lhs: FeedListFeed, rhs: FeedListFeed) -> Bool {
return lhs.hashValue == rhs.hashValue && lhs.url == rhs.url && lhs.name == rhs.name && lhs.homePageURL == rhs.homePageURL
}
}