Skip to content

Commit

Permalink
refactor toString method
Browse files Browse the repository at this point in the history
  • Loading branch information
fsimonjetz committed Feb 7, 2024
1 parent 1ad124e commit f6ea9e3
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions src/fragmentarium/domain/archaeology.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,25 +90,37 @@ export class Findspot {
return join([range, this.date?.notes], ', ')
}

toString(): string {
private get premises(): string {
const buildingType = _.capitalize(this.buildingType || '').replaceAll(
'_',
' '
)
const prefix = join([
return join([
padRight(this.area, ' >'),
this.building,
parenthesize(buildingType),
])
}

private get primaryContextString(): string {
switch (this.primaryContext) {
case true:
return 'primary context'
case false:
return 'secondary context'
case null:
return ''
}
}

toString(): string {
const layer = join([this.levelLayerPhase, parenthesize(this.dateString())])
const primaryContext = this.primaryContext
? 'primary context'
: _.isNull(this.primaryContext)
? ''
: 'secondary context'
const context = join([this.context, parenthesize(primaryContext)])
const context = join([
this.context,
parenthesize(this.primaryContextString),
])

const parts = join([prefix, layer, this.room, context], ', ')
const parts = join([this.premises, layer, this.room, context], ', ')

return padRight(join([parts, _.trimEnd(this.notes, '. ')], '. '), '.')
}
Expand Down

0 comments on commit f6ea9e3

Please sign in to comment.