line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::RunningTotal::Item; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
16
|
use 5.005; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
46
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
25
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
27
|
|
6
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
413
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
require Exporter; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub new { |
16
|
5
|
|
|
5
|
0
|
8
|
my $that = shift; |
17
|
5
|
|
33
|
|
|
20
|
my $class = ref($that) || $that; |
18
|
5
|
|
|
|
|
10
|
my ($rt, $numDims, $weight) = @_; |
19
|
|
|
|
|
|
|
|
20
|
5
|
|
50
|
|
|
26
|
my %state = (weight => $weight || 1, |
21
|
|
|
|
|
|
|
numDims => $numDims, |
22
|
|
|
|
|
|
|
rt => $rt |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
|
25
|
5
|
|
|
|
|
26
|
return bless(\%state); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub moveTo { |
31
|
10
|
|
|
10
|
0
|
44
|
my ($self, $time, %opts) = @_; |
32
|
|
|
|
|
|
|
|
33
|
10
|
50
|
|
|
|
30
|
croak("Expected an array ref for parameter 'coords'") if (ref($opts{coords}) ne "ARRAY"); |
34
|
10
|
50
|
|
|
|
10
|
if (scalar(@{$opts{coords}}) != $self->{rt}->{numDims}) { |
|
10
|
|
|
|
|
31
|
|
35
|
0
|
|
|
|
|
0
|
croak("Expected $self->{numDims} coordinates, but ".scalar(@{$opts{coords}})." given"); |
|
0
|
|
|
|
|
0
|
|
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
10
|
50
|
33
|
|
|
25
|
if (defined($self->{lastTime}) && |
39
|
|
|
|
|
|
|
$time < $self->{lastTime}) { |
40
|
0
|
|
|
|
|
0
|
carp("Item can't be moved to time in the past. Previous time moved: $self->{lastTime}. Current movement time: $time"); |
41
|
0
|
|
|
|
|
0
|
return; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
10
|
100
|
|
|
|
22
|
if (defined($self->{lastCoords})) { |
45
|
5
|
|
|
|
|
17
|
$self->{rt}->dec($time, weight => $self->{weight}, coords => $self->{lastCoords}); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
10
|
|
|
|
|
14
|
@{$self->{lastCoords}} = @{$opts{coords}}; |
|
10
|
|
|
|
|
33
|
|
|
10
|
|
|
|
|
15
|
|
49
|
|
|
|
|
|
|
|
50
|
10
|
|
|
|
|
39
|
$self->{rt}->inc($time, weight => $self->{weight}, coords => $self->{lastCoords}); |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
__END__ |