File Coverage

blib/lib/POE/Framework/MIDI/Rule/MinimumNoteCount.pm
Criterion Covered Total %
statement 12 25 48.0
branch 0 12 0.0
condition n/a
subroutine 4 7 57.1
pod 0 3 0.0
total 16 47 34.0


line stmt bran cond sub pod time code
1             # $Id: MinimumNoteCount.pm,v 1.1.1.1 2004/11/22 17:52:11 root Exp $
2              
3             package POE::Framework::MIDI::Rule::MinimumNoteCount;
4              
5 1     1   1177 use strict;
  1         3  
  1         31  
6 1     1   4 use vars '$VERSION'; $VERSION = '0.02';
  1         2  
  1         50  
7 1     1   4 use vars '@ISA';
  1         2  
  1         43  
8             @ISA = 'POE::Framework::MIDI::Rule';
9 1     1   5 use POE::Framework::MIDI::Rule;
  1         2  
  1         242  
10              
11             # test whatever we're passed
12             sub test {
13 0     0 0   my ($self, $thing_to_test) = @_;
14 0 0         die 'usage: $result = $rule->test(\@a_bar)'
15             unless ref($thing_to_test) eq 'ARRAY';
16 0           $self->{notecount} = undef;
17 0           for (@$thing_to_test) {
18 0 0         $_->{note} ? ++$self->{notecount} : next;
19             }
20 0 0         print "saw $self->{notecount} notes in $thing_to_test\n"
21             if $self->{params}->{verbose};
22 0 0         $self->{notecount} >= $self->min_notes ? return 1 : return;
23             }
24              
25             sub min_notes {
26 0     0 0   my $self = shift;
27 0 0         die 'no min_notes set in ' .__PACKAGE__.' params'
28             unless $self->{params}->{min_notes};
29 0           return $self->{params}->{min_notes};
30             }
31              
32             sub notecount {
33 0     0 0   my $self = shift;
34 0 0         $self->{notecount} = '0' unless $self->{notecount};
35 0           return $self->{notecount};
36             }
37              
38             1;
39              
40             __END__