-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathThumbnail.swift
More file actions
35 lines (28 loc) · 770 Bytes
/
Thumbnail.swift
File metadata and controls
35 lines (28 loc) · 770 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import Foundation
enum ImageType {
case portrait
case landscape
case square
case fullsize
var string: String {
switch self {
case .portrait: return "/portrait_fantastic"
case .landscape: return "/landscape_xlarge"
case .square: return "/standard_xlarge"
case .fullsize: return ""
}
}
}
struct Thumbnail: Codable {
private let path: String
private let `extension`: String
func url(for type: ImageType = .square) -> URL {
let urlString = path + type.string + "." + self.extension
return URL(string: urlString)!
}
init(path: String, extension: String) {
self.path = path
self.extension = `extension`
}
}
extension Thumbnail: Equatable {}