File Coverage

blib/lib/Video/Event/Manual.pm
Criterion Covered Total %
statement 6 34 17.6
branch 0 14 0.0
condition 0 6 0.0
subroutine 2 7 28.5
pod 0 5 0.0
total 8 66 12.1


line stmt bran cond sub pod time code
1             package Video::Event::Manual;
2              
3 2     2   16 use vars qw($VERSION @EXPORT);
  2         4  
  2         155  
4             $VERSION = 0.01;
5             @EXPORT = qw(new endtime tag gettag matches);
6              
7 2     2   10 use base Video::Event;
  2         2  
  2         1094  
8              
9             sub new {
10 0     0 0   my ($class, $time, $envelope, $probability, $type, $name) = @_;
11              
12             =pod
13             don't confuse $probability with envelope for coolness function
14             $probability is the probability that the event actually happened,
15             independent of how interesting the event was.
16             =cut
17              
18 0   0       my $self = bless {}, ref($class) || $class;
19 0           $self->{'time'} = $time;
20 0           $self->{'envelope'} = $envelope;
21 0           $self->{'probability'} = $probability;
22 0 0         $self->{'type'} = $type if $type;
23 0 0         $self->{'name'} = $name if $name;
24 0           return $self;
25             }
26              
27             sub endtime {
28 0     0 0   my ($self, $eventtime, $coolness) = @_;
29 0           my $totaltime = $eventtime - $self->{'time'};
30 0           $self->{'endtime'} = $eventtime;
31 0           $self->{'cool'} = $coolness;
32 0           return $totaltime;
33             }
34              
35             sub tag {
36 0     0 0   my ($self, $tag) = @_;
37 0 0         if ($self->gettag()) {
38 0           $self->{'tag'} .= $tag;
39             }
40             else {
41 0           $self->{'tag'} = $tag;
42             }
43 0           return 1;
44             }
45              
46             sub matches {
47 0     0 0   my ($self, $searchterm, $tags) = @_;
48 0 0 0       if (ref $tags eq 'ARRAY' or $tags eq 'all') {
49 0           foreach my $tag (@tags) {
50             #hooray for perl 6
51 0 0         return 1 if ($self->gettag() eq $tag);
52             }
53 0           return 0;
54             }
55             #if no tags specified, look in name
56             else {
57 0 0         return 1 if ($self->{'name'} =~ /$searchterm/);
58 0           return 0;
59             }
60             }
61              
62             sub gettag {
63 0     0 0   my ($self) = @_;
64 0 0         return $self->{'tag'} if defined $self->{'tag'};
65 0           return $self->{'name'};
66             }
67              
68             1;