-
Notifications
You must be signed in to change notification settings - Fork 104
/
URLBox.swift
53 lines (41 loc) · 874 Bytes
/
URLBox.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
//
// URLBox.swift
// XMLCoder
//
// Created by Vincent Esche on 12/21/18.
//
import Foundation
struct URLBox: Equatable {
typealias Unboxed = URL
let unboxed: Unboxed
init(_ unboxed: Unboxed) {
self.unboxed = unboxed
}
init?(xmlString: String) {
guard let unboxed = Unboxed(string: xmlString) else {
return nil
}
self.init(unboxed)
}
func unbox() -> Unboxed {
return self.unboxed
}
}
extension URLBox: Box {
var isNull: Bool {
return false
}
var isFragment: Bool {
return true
}
func xmlString() -> String? {
return self.unboxed.absoluteString
}
}
extension URLBox: SimpleBox {
}
extension URLBox: CustomStringConvertible {
var description: String {
return self.unboxed.description
}
}