lib/Schedule/Chronic/Timer.pm

filter: Statementstmt 5.5% 1 / 18 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 6 totaltotal 2.9% 1 / 34 CC 3 SCAR 17.5
CC
3
Cov
5%
get
12.0
new
2.0
set
2.0
CRAP 5.8
« lib/Schedule/Chronic/Logger.pm ↑ Summary lib/Schedule/Chronic/Constraint/Freq.pm »
1 ##
2 ## Timer Class for Chronic Scheduler
3 ## Author: Vipul Ved Prakash <mail@vipul.net>.
4 ## $Id: Timer.pm,v 1.2 2004/08/15 21:02:36 hackworth Exp $
5  
6 package Schedule::Chronic::Timer;
7  
8 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
9  
10 0 my ($class, $direction) = @_;
11  
12 0 my $self = bless {
13 value => 0,
14 starttime => time(),
15 direction => $direction,
16 running => 0,
17 }, $class;
18  
19 0 return $self;
20  
21 }
22  
23  
24 0 ▶sub set {
Subroutine set: not called CC=1 SCAR=6.9
Pod undocumented
25  
26 0 $_[0]->{value} = $_[1];
27 0 $_[0]->{starttime} = time();
28 0 $_[0]->start();
29  
30 }
31  
32  
33  
34 0 ▶sub start {
Subroutine start: not called CC=1 SCAR=6.9
Pod undocumented
35  
36 0 $_[0]->{running} = 1;
37  
38 }
39  
40  
41 0 ▶sub stop {
Subroutine stop: not called CC=1 SCAR=6.9
Pod undocumented
42  
43 0 $_[0]->{running} = 0;
44  
45 }
46  
47  
48 0 ▶sub running {
Subroutine running: not called CC=1 SCAR=6.9
Pod undocumented
49  
50 0 $_[0]->{running};
51  
52 }
53  
54  
55 0 ▶sub get {
Subroutine get: not called CC=3 SCAR=24.8
Pod undocumented
56  
57 0 my $self = shift;
58 0 my $ticks = 0;
59  
60 0 ▶ if ($self->{running}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'running'}) { } 0 0 0
61 0 ▶ if ($self->{direction} eq 'up') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'direction'} eq 'up') { } 0 0 0
62 0 $ticks = $self->{value} - (time() - $self->{starttime});
63 } else {
64 0 $ticks = ($self->{value} + $self->{starttime}) - time();
65 }
66 } else {
67 0 return $self->{value};
68 }
69  
70 0 return $ticks;
71  
72 }
73  
74  
75 1 1;
76  
« lib/Schedule/Chronic/Logger.pm ↑ Summary lib/Schedule/Chronic/Constraint/Freq.pm »