Piece

@Serializable(with = PieceSerializer::class)
data class Piece(val number: Int, val title: String, val lines: List<String>, val cutSizes: Map<String, List<Int>> = emptyMap())(source)

What a reader reads in one sitting: a sonnet, a stanza, a scene.

Creating or decoding a piece refuses cuts that do not divide its lines: each stage named in cutSizes has to be a reading stage other than ReadingStage.LINE, and its sizes have to be positive and add up to exactly the number of lines. The number is not validated against a work.

Throws

, WorkCorpus.WorkShapeError.CutsForLineStage, WorkCorpus.WorkShapeError.EmptyCut or WorkCorpus.WorkShapeError.CutsDoNotCoverThePiece naming the piece and the stage when the cuts do not divide the lines, the stages judged in code-point order of their names.

naming the field when the number or a cut size decoded from YAML or JSON is not a whole number within 32 bits.

naming the field when a decoded title or line is null.

when a decoded piece misses a field or a field holds another kind of value than it names.

Constructors

Link copied to clipboard
constructor(number: Int, title: String, lines: List<String>, cutSizes: Map<String, List<Int>> = emptyMap())

Properties

Link copied to clipboard

Per-stage sizes of consecutive line groups, keyed by ReadingStage.label. A work that names no cuts, or names them as null, decodes with an empty table.

Link copied to clipboard
val id: Int

Stable identity, equal to the piece number.

Link copied to clipboard

Printed lines in reading order.

Link copied to clipboard
val number: Int

One-based position of the piece in its work.

Link copied to clipboard

First printed line, or an empty string when the piece has no lines.

Link copied to clipboard

Reader-facing title.

Functions

Link copied to clipboard

The line ranges a reader takes in one attempt at this stage.