lib/News/GroupInfo/Entry.pm

filter: Statementstmt 26.0% 6 / 23 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 19 MC/DCmcdc 0.0% 0 / 10 Subroutinesub 11.1% 1 / 9 Podpod 100% 8 / 8 totaltotal 18.9% 15 / 79 CC 15 SCAR 31.6
CC
15
Cov
12%
new
56.0
name
12.0
desc
12.0
CRAP 23.6
« lib/News/Active/Entry.pm ↑ Summary lib/News/Article/Mbox.pm »
1 1 $VERSION = "0.10";
2 package News::GroupInfo::Entry;
3 1 our $VERSION = "0.10";
4  
5 # -*- Perl -*- # Wed Apr 28 09:38:34 CDT 2004
6 ###############################################################################
7 # Written by Tim Skirvin <tskirvin@killfile.org>. Copyright 2003-2004,
8 # Tim Skirvin. Redistribution terms are below.
9 ###############################################################################
10  
11 =head1 NAME
12  
13 News::GroupInfo::Entry - an object for storing specific group information
14  
15 =head1 SYNOPSIS
16  
17 use News::GroupInfo::Entry;
18  
19 See News::GroupInfo and below for more specific information about related
20 functions.
21  
22 =head1 DESCRIPTION
23  
24 News::GroupInfo::Entry contains the actual newsgroup entries for
25 News::GroupInfo. Each entry consists of a group name, timestamp of
26 creation, creator name, and group description. Within that, it is a very
27 simple module (significantly more lines dedicated to documentation than
28 actual code).
29  
30 =head1 USAGE
31  
32 News::GroupInfo::Entry is accessed through the following functions:
33  
34 =cut
35  
36 ###############################################################################
37 ### main() ####################################################################
38 ###############################################################################
39  
40 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
41  
42 =head2 Functions
43  
44 =over 4
45  
46 =item new ( STRING )
47  
48 Creates and returns a new News::GroupInfo::Entry object. C<STRING> is a
49 scalar containing the group name, timestamp of creation, creator name, and
50 group description, separated by '::'.
51  
52 Only the group name is really required; the rest will be worked on on
53 their own. Therefore, just passing in the group name will work fine.
54  
55 =cut
56  
57 0 ▶sub new {
Subroutine new: not called CC=7 SCAR=40.3
Pod documented
58 0 my ($proto, $string) = @_;
59 0 my ($group, $time, $creator, $desc) = split('::', $string);
60 0 ▶ return undef unless $group;
Branch: 1 branch
BranchTrueFalseTotal
unless $group 0 0 0
61 0 ▶ my $class = ref($proto) || $proto;
Condition0%0/3
ref $proto || $proto
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $proto || $proto
ref $proto $proto
Truth table0%0/3
A || B
A= ref $protoB= $proto
ABresult
1X1
011
000
62 0 ▶ my $self = {
Condition0%0/8
$group || ''
l!l
00
$desc || ''
l!l
00
$creator || ''
l!l
00
$time || 0
l!l
00
MC/DC0%0/1
$group || ''
$group
MC/DC0%0/1
$desc || ''
$desc
MC/DC0%0/1
$creator || ''
$creator
MC/DC0%0/1
$time || 0
$time
Truth table0%0/2
A
A= $group
Aresult
11
00
Truth table0%0/2
A
A= $desc
Aresult
11
00
Truth table0%0/2
A
A= $creator
Aresult
11
00
Truth table0%0/2
A
A= $time
Aresult
11
00
63 'name' => $group || '',
64 'desc' => $desc || '',
65 'creator' => $creator || '',
66 'time' => $time || 0,
67 };
68 0 bless $self, $class;
69 }
70  
71 =item name ( [STRING] )
72  
73 =item desc ( [STRING] )
74  
75 =item creator ( [STRING] )
76  
77 =item time ( [STRING] )
78  
79 Returns the relevant information from the object, as indicated above. If
80 an argument is passed to these functions, then the value is set to that
81 value; otherwise, we just return the existing value.
82  
83 =cut
84  
85 0 ▶sub name { defined $_[1] ? $_[0]->{name} = $_[1] : $_[0]->{name} || "" }
Subroutine name: not called CC=3 SCAR=24.8
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
defined $_[1] ? : 0 0 0
Condition0%0/2
$_[0]{"name"} or ""
l!l
00
MC/DC0%0/1
$_[0]{"name"} or ""
$_[0]{"name"}
Truth table0%0/2
A
A= $_[0]{"name"}
Aresult
11
00
86 0 ▶sub desc { defined $_[1] ? $_[0]->{desc} = $_[1] : $_[0]->{desc} || "" }
Subroutine desc: not called CC=3 SCAR=24.8
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
defined $_[1] ? : 0 0 0
Condition0%0/2
$_[0]{"desc"} or ""
l!l
00
MC/DC0%0/1
$_[0]{"desc"} or ""
$_[0]{"desc"}
Truth table0%0/2
A
A= $_[0]{"desc"}
Aresult
11
00
87 0 ▶sub creator { defined $_[1] ? $_[0]->{creator} = $_[1] : $_[0]->{creator} || ""}
Subroutine creator: not called CC=3 SCAR=24.8
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
defined $_[1] ? : 0 0 0
Condition0%0/2
$_[0]{"creator"} or ""
l!l
00
MC/DC0%0/1
$_[0]{"creator"} or ""
$_[0]{"creator"}
Truth table0%0/2
A
A= $_[0]{"creator"}
Aresult
11
00
88 0 ▶sub time { defined $_[1] ? $_[0]->{'time'} = $_[1] : $_[0]->{'time'} || 0 }
Subroutine time: not called CC=3 SCAR=24.8
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
defined $_[1] ? : 0 0 0
Condition0%0/2
$_[0]{"time"} or 0
l!l
00
MC/DC0%0/1
$_[0]{"time"} or 0
$_[0]{"time"}
Truth table0%0/2
A
A= $_[0]{"time"}
Aresult
11
00
89  
90 =item arrayref ()
91  
92 Returns an array reference containing C<time()>, C<creator()>, and
93 C<desc()> (the same information stored by INN's various newsgroup files).
94  
95 =cut
96  
97 0 ▶sub arrayref { my ($self) = @_; [ $self->time, $self->creator, $self->desc ]; }
Subroutine arrayref: not called CC=1 SCAR=6.9
Pod documented
98  
99 =item print ()
100  
101 Makes a human-readable string containing the information from arrayref().
102  
103 =cut
104  
105 0 ▶sub print { join("\t", @{shift->arrayref}) }
Subroutine print: not called CC=1 SCAR=6.9
Pod documented
106  
107 =item output ()
108  
109 Returns the string that is needed by new() - ie, a string containing
110 name() and arrayref(), separated by '::'.
111  
112 =cut
113  
114 0 ▶sub output { my $self = shift; join("::", $self->name, @{$self->arrayref}) }
Subroutine output: not called CC=1 SCAR=6.9
Pod documented
115  
116 =back
117  
118 =cut
119  
120 1 1;
121  
122 =head1 REQUIREMENTS
123  
124 B<News::GroupInfo>
125  
126 =head1 SEE ALSO
127  
128 B<News::GroupInfo>
129  
130 =head1 AUTHOR
131  
132 Tim Skirvin <tskirvin@killfile.org>
133  
134 =head1 HOMEPAGE
135  
136 B<http://www.killfile.org/~tskirvin/software/news-archive/>
137  
138 =head1 LICENSE
139  
140 This code may be redistributed under the same terms as Perl itself.
141  
142 =head1 COPYRIGHT
143  
144 Copyright 2003-2004, Tim Skirvin.
145  
146 =cut
147  
148 ###############################################################################
149 ##### Version History #########################################################
150 ###############################################################################
151 # v0.10 Wed Apr 28 09:44:47 CDT 2004
152 ### First documented version; it's been working since last year, though.
« lib/News/Active/Entry.pm ↑ Summary lib/News/Article/Mbox.pm »