Parse server num and free bit

This commit is contained in:
Davide De Rosa 2019-03-24 23:36:21 +01:00
parent 838f097d65
commit 65b6cdccbf
1 changed files with 17 additions and 2 deletions

View File

@ -36,6 +36,10 @@ public struct Pool: Codable, Comparable, CustomStringConvertible {
case area
case num
case isFree = "free"
// case location
case hostname
@ -51,6 +55,10 @@ public struct Pool: Codable, Comparable, CustomStringConvertible {
public let area: String?
public let num: String?
public let isFree: Bool?
// public let location: (Double, Double)
public let hostname: String
@ -93,10 +101,17 @@ extension Pool {
public var localizedCountryArea: String {
let countryString = localizedCountry
guard let area = area else {
let zone: String
if let area = area, let num = num {
zone = "\(area) #\(num)"
} else if let area = area {
zone = area
} else if let num = num {
zone = "#\(num)"
} else {
return countryString
}
return String.init(format: Pool.localizedFormat, countryString, area.uppercased())
return String.init(format: Pool.localizedFormat, countryString, zone.uppercased())
}
public var localizedName: String {