Created
May 6, 2019 09:56
-
-
Save giln/8243d448b2b79518a56eb9c5ffb15b4a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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