This repository was archived by the owner on Sep 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathSubredditListRankingTargetType.swift
65 lines (59 loc) · 1.72 KB
/
SubredditListRankingTargetType.swift
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//
// SubredditListRankingTargetType.swift
// reddift
//
// Created by sonson on 2016/08/11.
// Copyright © 2016年 sonson. All rights reserved.
//
import Foundation
/**
"Safe For Work" flag type of ranking data at redditlist.com.
This type is used for creating title for view controller, tab bar title and URL for json.
This type has NSFW, SFW and all.
*/
enum SubredditListRankingTargetType {
case All
case NSFW
case SFW
init(viewController: SubredditListRankingViewController) {
if viewController.isKind(of: SubredditListAllRankingViewController.self) {
self = .All
} else if viewController.isKind(of: SubredditListNSFWRankingViewController.self) {
self = .NSFW
} else if viewController.isKind(of: SubredditListSFWRankingViewController.self) {
self = .SFW
} else {
self = .All
}
}
var tabbarTitle: String {
switch self {
case .All:
return "Ranking - All"
case .NSFW:
return "Ranking - NSFW"
case .SFW:
return "Ranking - SFW"
}
}
var title: String {
switch self {
case .All:
return "Ranking - All subreddits"
case .NSFW:
return "Ranking - NSFW subreddits"
case .SFW:
return "Ranking - SFW subreddits"
}
}
var url: URL {
switch self {
case .All:
return URL(string: "https://api.reddift.net/all_ranking.json")!
case .NSFW:
return URL(string: "https://api.reddift.net/nsfw_ranking.json")!
case .SFW:
return URL(string: "https://api.reddift.net/sfw_ranking.json")!
}
}
}