blob: ef9eb9b00bbaab5c17c0d69801557d8835f96373 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
package reading.models
case class Book (
title: String,
author: String,
period: Period,
genres: Seq[Genre],
themes: Seq[Theme],
program: Program,
pages: Int
) extends Ordered[Book] {
def compare(that: Book) = {
def formatTitle(title: String) =
title.toLowerCase.replaceAll("^les ", "").replaceAll("^le ", "")
formatTitle(this.title).compare(formatTitle(that.title))
}
}
object Book {
def filter(books: Seq[Book], filters: Seq[Filter]): Seq[Book] =
books.filter(b => filters.forall(_.filter(b)))
}
|