line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::OpeningHours::Hours; |
2
|
3
|
|
|
3
|
|
57793
|
use strict; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
131
|
|
3
|
3
|
|
|
3
|
|
17
|
use warnings; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
1311
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
sub new { |
6
|
21
|
|
|
21
|
0
|
44
|
my ($class, $pairs) = @_; |
7
|
|
|
|
|
|
|
|
8
|
21
|
|
|
|
|
74
|
my $self = bless { |
9
|
|
|
|
|
|
|
pairs => $pairs, |
10
|
|
|
|
|
|
|
}, $class; |
11
|
|
|
|
|
|
|
|
12
|
21
|
|
|
|
|
77
|
return bless $self, $class; |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub is_open_between { |
16
|
21
|
|
|
21
|
0
|
36
|
my ($self, $hour) = @_; |
17
|
21
|
|
|
|
|
25
|
for (@{$self->{pairs}}) { |
|
21
|
|
|
|
|
58
|
|
18
|
18
|
100
|
|
|
|
41
|
if ($self->is_pair_open_between($_, $hour)) { |
19
|
12
|
|
|
|
|
58
|
return 1; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
} |
22
|
9
|
|
|
|
|
39
|
return; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub is_pair_open_between { |
26
|
18
|
|
|
18
|
0
|
24
|
my ($self, $pair, $hour) = @_; |
27
|
18
|
|
100
|
|
|
123
|
return $pair->[0] le $hour && $pair->[1] gt $hour; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub first_hour { |
31
|
5
|
|
|
5
|
0
|
7
|
my ($self) = @_; |
32
|
5
|
|
|
|
|
21
|
return $self->{pairs}[0][0]; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
1; |