line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::Page::Pageset::Chunk; |
2
|
2
|
|
|
2
|
|
12
|
use Carp; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
91
|
|
3
|
2
|
|
|
2
|
|
13
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
50
|
|
4
|
2
|
|
|
2
|
|
8
|
use base 'Class::Accessor::Fast'; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
919
|
|
5
|
|
|
|
|
|
|
use overload |
6
|
2
|
|
|
2
|
|
7434
|
'""' => sub { shift->as_string }; |
|
2
|
|
|
8
|
|
2327
|
|
|
2
|
|
|
|
|
19
|
|
|
8
|
|
|
|
|
267
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors( qw( first last pages is_current ) ); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = sprintf "%d.%02d", q$Revision: 1.2 $ =~ /: (\d+)\.(\d+)/; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
13
|
10
|
|
|
10
|
1
|
17
|
my $class = shift; |
14
|
10
|
|
|
|
|
17
|
my @array = @_; |
15
|
|
|
|
|
|
|
|
16
|
10
|
|
|
|
|
31
|
my $self = bless {}, $class; |
17
|
10
|
|
|
|
|
32
|
$self->first( $array[0] ); |
18
|
10
|
|
|
|
|
169
|
$self->last( $array[-1] ); |
19
|
10
|
|
|
|
|
65
|
$self->pages( $#array + 1 ); |
20
|
10
|
|
|
|
|
62
|
$self->is_current(0); |
21
|
|
|
|
|
|
|
|
22
|
10
|
|
|
|
|
64
|
return $self; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub middle { |
26
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
27
|
0
|
|
|
|
|
0
|
my $pages = $self->pages; |
28
|
0
|
0
|
|
|
|
0
|
$pages++ if $pages % 2; |
29
|
0
|
|
|
|
|
0
|
return $self->first + $pages / 2; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub as_string { |
33
|
8
|
|
|
8
|
0
|
13
|
my $self = shift; |
34
|
8
|
|
50
|
|
|
33
|
my $sep = shift || '-'; |
35
|
8
|
50
|
|
|
|
25
|
my $string = ( $self->first == $self->last ) |
36
|
|
|
|
|
|
|
? $self->first |
37
|
|
|
|
|
|
|
: join ("$sep", $self->first, $self->last ); |
38
|
8
|
|
|
|
|
149
|
return $string; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
1; |