1 package Text::Tradition::Collation::Reading;
4 use overload '""' => \&_stringify, 'fallback' => 1;
5 use Text::Tradition::Collation;
9 Text::Tradition::Collation::Reading - represents a reading (usually a word) in a collation.
13 Text::Tradition is a library for representation and analysis of collated
14 texts, particularly medieval ones. A 'reading' refers to a unit of text,
15 usually a word, that appears in one or more witnesses (manuscripts) of the
16 tradition; the text of a given witness is composed of a set of readings in
23 Creates a new reading in the given collation with the given attributes.
28 =item collation - The Text::Tradition::Collation object to which this reading belongs. Required.
30 =item id - A unique identifier for this reading. Required.
32 =item text - The word or other text of the reading.
34 =item is_start - The reading is the starting point for the collation.
36 =item is_end - The reading is the ending point for the collation.
38 =item is_lacuna - The 'reading' represents a known gap in the text.
40 =item rank - The sequence number of the reading. This should probably not be set manually.
44 One of 'text', 'is_start', 'is_end', or 'is_lacuna' is required.
60 Accessor methods for the given attributes.
66 isa => 'Text::Tradition::Collation',
81 writer => 'alter_text',
105 predicate => 'has_rank',
109 around BUILDARGS => sub {
119 # If one of our special booleans is set, we change the text and the
122 if( exists $args->{'is_lacuna'} && !exists $args->{'text'} ) {
123 $args->{'text'} = sprintf( "#LACUNA_%s#", $args->{'id'} );
124 } elsif( exists $args->{'is_start'} ) {
125 $args->{'id'} = '#START#'; # Change the ID to ensure we have only one
126 $args->{'text'} = '#START#';
128 } elsif( exists $args->{'is_end'} ) {
129 $args->{'id'} = '#END#'; # Change the ID to ensure we have only one
130 $args->{'text'} = '#END#';
133 $class->$orig( $args );
138 A meta attribute (ha ha), which should be true if any of our 'special'
139 booleans are true. Implies that the reading does not represent a bit
140 of text found in a witness.
146 return $self->is_start || $self->is_end || $self->is_lacuna;
149 # Some syntactic sugar
150 sub related_readings {
152 return $self->collation->related_readings( $self, @_ );
156 my( $self, $other ) = @_;
157 return $self->collation->add_relationship( $self, $other,
158 { 'type' => 'transposition' } );
167 __PACKAGE__->meta->make_immutable;