Sort returned entities
This commit is contained in:
parent
bb61b15265
commit
45f56f01e3
@ -14,18 +14,19 @@ protocol TwitterEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
extension TwitterEntity {
|
extension TwitterEntity {
|
||||||
var startIndex: Int? {
|
|
||||||
if indices?.count ?? 0 > 0 {
|
var startIndex: Int {
|
||||||
return indices?[0]
|
if let indices = indices, indices.count > 0 {
|
||||||
|
return indices[0]
|
||||||
}
|
}
|
||||||
return nil
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
var endIndex: Int? {
|
var endIndex: Int {
|
||||||
if indices?.count ?? 0 > 1 {
|
if let indices = indices, indices.count > 1 {
|
||||||
return indices?[1]
|
return indices[1]
|
||||||
}
|
}
|
||||||
return nil
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -58,7 +59,7 @@ struct TwitterEntities: Codable {
|
|||||||
if let symbols = symbols {
|
if let symbols = symbols {
|
||||||
entities.append(contentsOf: symbols)
|
entities.append(contentsOf: symbols)
|
||||||
}
|
}
|
||||||
return entities
|
return entities.sorted(by: { $0.startIndex < $1.startIndex })
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,13 @@ struct TwitterHashtag: Codable, TwitterEntity {
|
|||||||
case indices = "indices"
|
case indices = "indices"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var startIndex: Int {
|
||||||
|
if let indices = indices, indices.count > 0 {
|
||||||
|
return indices[0] - 1
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
func renderAsHTML() -> String {
|
func renderAsHTML() -> String {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,13 @@ struct TwitterSymbol: Codable, TwitterEntity {
|
|||||||
case indices = "indices"
|
case indices = "indices"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var startIndex: Int {
|
||||||
|
if let indices = indices, indices.count > 0 {
|
||||||
|
return indices[0] - 1
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
func renderAsHTML() -> String {
|
func renderAsHTML() -> String {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user