line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# $Id: DB.pm,v 1.2 2004/03/31 20:28:46 claes Exp $ |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package WWW::Search::Tv::Sweden::TvDotNu::DB; |
4
|
1
|
|
|
1
|
|
8
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
573
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
sub new { |
7
|
2
|
|
|
2
|
0
|
6
|
my $class = shift; |
8
|
2
|
|
33
|
|
|
19
|
$class = ref($class) || $class; |
9
|
2
|
|
|
|
|
5
|
my $entries = shift; |
10
|
2
|
100
|
66
|
|
|
17
|
$entries = defined $entries && ref $entries eq 'ARRAY' ? $entries : []; |
11
|
2
|
|
|
|
|
22
|
bless { |
12
|
|
|
|
|
|
|
entries => $entries, |
13
|
|
|
|
|
|
|
}, $class; |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub add { |
17
|
0
|
|
|
0
|
0
|
0
|
my ($self, $entry) = @_; |
18
|
0
|
|
|
|
|
0
|
push @{$self->{entries}}, $entry; |
|
0
|
|
|
|
|
0
|
|
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub last { |
22
|
0
|
|
|
0
|
0
|
0
|
my ($self) = @_; |
23
|
0
|
|
|
|
|
0
|
return ${$self->{entries}}[-1]; |
|
0
|
|
|
|
|
0
|
|
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub channels { |
27
|
0
|
|
|
0
|
0
|
0
|
my ($self) = @_; |
28
|
0
|
|
|
|
|
0
|
my %channels = map { $_->channel => 1 } @{$self->{entries}}; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
29
|
0
|
|
|
|
|
0
|
return keys %channels; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub for_channel { |
33
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
34
|
0
|
|
|
|
|
0
|
my @entries; |
35
|
|
|
|
|
|
|
|
36
|
0
|
0
|
|
|
|
0
|
die "Must supply channels" unless @_; |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
0
|
my $channels = "^(?:" . join("|", @_) . ")\$"; |
39
|
0
|
|
|
|
|
0
|
my $re = qr/$channels/i; |
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
0
|
@entries = grep { lc($_->channel) =~ $re } @{$self->{entries}}; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
0
|
return WWW::Search::Tv::Sweden::TvDotNu::DB->new(\@entries); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub between { |
47
|
1
|
|
|
1
|
0
|
88
|
my ($self, $start_hour, $start_min, $end_hour, $end_min) = @_; |
48
|
|
|
|
|
|
|
|
49
|
1
|
|
|
|
|
2
|
my @entries = grep { $_->in($start_hour, $start_min, $end_hour, $end_min) } @{$self->{entries}}; |
|
0
|
|
|
|
|
0
|
|
|
1
|
|
|
|
|
9
|
|
50
|
1
|
|
|
|
|
9
|
return WWW::Search::Tv::Sweden::TvDotNu::DB->new(\@entries); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub entries { |
55
|
1
|
|
|
1
|
0
|
2
|
my ($self) = @_; |
56
|
1
|
|
|
|
|
3
|
return @{$self->{entries}}; |
|
1
|
|
|
|
|
4
|
|
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
1; |