Skip to content

Instantly share code, notes, and snippets.

@giln
Created May 6, 2019 09:56
Show Gist options
  • Select an option

  • Save giln/8243d448b2b79518a56eb9c5ffb15b4a to your computer and use it in GitHub Desktop.

Select an option

Save giln/8243d448b2b79518a56eb9c5ffb15b4a to your computer and use it in GitHub Desktop.
extension Movie: Listable {
private static let dateFormatter: DateFormatter = {
let formatter = DateFormatter()
formatter.dateStyle = .medium
formatter.timeStyle = .none
return formatter
}()
public var firstText: String {
return title
}
public var secondText: String {
return overview
}
public var thirdText: String {
return Movie.dateFormatter.string(from: releaseDate)
}
public var fourthText: String {
let rating = Int(voteAverage)
let ratingText = (0 ..< rating).reduce("") { (acc, _) -> String in
return acc + "⭐️"
}
return ratingText
}
public var imageUrl: URL {
return posterURL
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment