private let rawValue: String?
var int: Int? { return rawValue.flatMap { Int($0) } }
+
var double: Double? { return rawValue.flatMap { Double($0) } }
+
var string: String? { return rawValue }
+
var bool: Bool? {
- guard let _ = rawValue else { return nil }
+ guard let _ = rawValue else {
+
+ return nil
+ }
if let i = self.int {
if let s = self.string?.lowercased() {
switch s {
+
case "true", "yes", "t", "y": return true
default: return false
+
}
}
return false
}
+
var array: [ParameterValue] {
return rawValue?.components(separatedBy: ",").map { ParameterValue($0) } ?? []
}
+
var integerArray: [Int] {
- return array.flatMap { $0.int }
+ return array.compactMap { $0.int }
}
var valid: Bool { return rawValue != nil }
init?(_ request: URLRequest) {
- guard let paramList = parseParameter(request) else { return nil }
+ guard let paramList = parseParameter(request) else {
+
+ return nil
+ }
self.init(paramList)
}
extension Parameter: Equatable {
public static func == (lhs: Parameter, rhs: Parameter) -> Bool {
+
return lhs.rawValue == rhs.rawValue
}
}