GedNav/Source.pm untested

filter: Statementstmt 0.0% 0 / 40 Branchbran 0.0% 0 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 10 Podpod 0.0% 0 / 8 totaltotal 0.0% 0 / 70 CC 7 SCAR 19.1
CC
7
Cov
0%
private
12.0
title
12.0
new
6.0
CRAP 6.8
1 package GedNav::Source;
2  
3 use GedNav::Family;
4 use GedNav::Event;
5  
6 sub new
7 {
8 my $type = shift;
9 $type = ref $type if ref $type;
10 my $parent = shift;
11 my $code = uc(shift);
12  
13 my $newobj = {
14 code => $code,
15 parent => $parent,
16 };
17  
18 warn "New source: code is $code\n";
19  
20 return bless $newobj, $type;
21 }
22  
23 sub parent
24 {
25 my $self = shift;
26 return $self->{'parent'};
27 }
28  
29 sub gedcom
30 {
31 my $self = shift;
32 return $self->parent->gedcom;
33 }
34  
35 sub dataset
36 {
37 my $self = shift;
38 return $self->gedcom->dataset;
39 }
40  
41 sub raw
42 {
43 my $self = shift;
44 my $attrname = 'raw';
45  
46 unless (exists $self->{$attrname})
47 {
48 $self->{$attrname} = $self->gedcom->_get_paragraph("sour:" . $self->code);
49 }
50  
51 return $self->{$attrname};
52 }
53  
54 sub code
55 {
56 my $self = shift;
57 return $self->{'code'};
58 }
59  
60 sub private
61 {
62 my $self = shift;
63 my $attrname = 'private';
64  
65 if (@_)
66 {
67 $self->{$attrname} = shift;
68 }
69  
70 return 1 if $self->gedcom->private;
71 return $self->{$attrname};
72 }
73  
74 sub title
75 {
76 my $self = shift;
77  
78 unless (exists $self->{'title'})
79 {
80 my @matches = grep { /^\d+\s+titl/i } @{$self->raw};
81 if (@matches)
82 {
83 ($self->{'titl'}) = ($matches[0] =~ /^\d+\s+titl\s+(.*)\s*$/i);
84 }
85 }
86  
87 return $self->{'titl'};
88 }
89  
90 ###
91  
92 1;
93