GedNav/Family.pm untested

filter: Statementstmt 0.0% 0 / 57 Branchbran 0.0% 0 / 16 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 9 totaltotal 0.0% 0 / 91 CC 9 SCAR 18.9
CC
9
Cov
0%
private
12.0
new
6.0
raw
6.0
CRAP 6.6
1 package GedNav::Family;
2  
3 sub new
4 {
5 my $type = shift;
6 $type = ref $type if ref $type;
7 my $gedcom = shift;
8 my $code = uc(shift);
9  
10 my $newobj = {
11 code => $code,
12 gedcom => $gedcom,
13 };
14  
15 return bless $newobj, $type;
16 }
17  
18 sub gedcom
19 {
20 my $self = shift;
21 return $self->{'gedcom'};
22 }
23  
24 sub raw
25 {
26 my $self = shift;
27 my $attrname = 'raw';
28  
29 unless (exists $self->{$attrname})
30 {
31 $self->{$attrname} = $self->gedcom->_get_paragraph("fam:" . $self->code)
32 }
33  
34 return $self->{$attrname};
35 }
36  
37 sub code
38 {
39 my $self = shift;
40 return $self->{'code'};
41 }
42  
43 sub private
44 {
45 my $self = shift;
46 my $attrname = 'private';
47  
48 if (@_)
49 {
50 $self->{$attrname} = shift;
51 }
52  
53 return 1 if $self->gedcom->private;
54 return $self->{$attrname};
55 }
56  
57 sub marriage
58 {
59 my $self = shift;
60 my $attrname = 'marriage';
61  
62 unless (exists $self->{$attrname})
63 {
64 $self->{$attrname} = GedNav::Event->new('marr', $self);
65 }
66  
67 return $self->{$attrname}
68 }
69  
70 sub husb
71 {
72 my $self = shift;
73 my $attrname = 'husb';
74  
75 unless (exists $self->{$attrname})
76 {
77 my @matches =
78 map { GedNav::Individual->new($self->gedcom, $_) }
79 map { /^\d+\s+husb\s@(.*)@/i }
80 grep { /^\d+\s+husb/i }
81 @{$self->raw};
82  
83 $self->{$attrname} = shift @matches;
84 }
85  
86 return $self->{$attrname};
87 }
88  
89 sub wife
90 {
91 my $self = shift;
92 my $attrname = 'wife';
93  
94 unless (exists $self->{$attrname})
95 {
96 my @matches =
97 map { GedNav::Individual->new($self->gedcom, $_) }
98 map { /^\d+\s+wife\s@(.*)@/i }
99 grep { /^\d+\s+wife/i }
100 @{$self->raw};
101  
102 $self->{$attrname} = shift @matches;
103 }
104  
105 return $self->{$attrname};
106 }
107  
108 sub children
109 {
110 my $self = shift;
111 my $attrname = 'children';
112  
113 unless (exists $self->{$attrname})
114 {
115 my @matches =
116 map { GedNav::Individual->new($self->gedcom, $_) }
117 map { /^\d+\s+chil\s@(.*)@/i }
118 grep { /^\d+\s+chil/i }
119 @{$self->raw};
120  
121 $self->{$attrname} = \@matches;
122 }
123  
124 return @{$self->{$attrname}};
125 }
126  
127 ###
128  
129 1;
130