got the graph calculated correctly from the spreadsheet
[scpubgit/stemmatology.git] / lib / Text / Tradition.pm
index 92673be..8e028a9 100644 (file)
@@ -24,9 +24,7 @@ has 'witnesses' => (
 
 sub BUILD {
     my( $self, $init_args ) = @_;
-    print STDERR "Calling tradition build\n";
 
-    $DB::single = 1;
     if( exists $init_args->{'witnesses'} ) {
        # We got passed an uncollated list of witnesses.  Make a
        # witness object for each witness, and then send them to the
@@ -88,10 +86,23 @@ sub BUILD {
     }
 }
 
+sub witness {
+    my( $self, $sigil ) = @_;
+    my $requested_wit;
+    foreach my $wit ( @{$self->witnesses} ) {
+       $requested_wit = $wit if $wit->sigil eq $sigil;
+    }
+    # We depend on an undef return value for no such witness.
+    # warn "No such witness $sigil" unless $requested_wit;
+    return $requested_wit;
+}
+       
+
 sub add_witness {
     my $self = shift;
     my $new_wit = Text::Tradition::Witness->new( @_ );
     push( @{$self->witnesses}, $new_wit );
+    return $new_wit;
 }
 
 # The user will usually be instantiating a Tradition object, and