| 1 | package Sim::Clock; | ||||||||||
| 2 | |||||||||||
| 3 | 4 | ▶ | use Carp qw(croak carp); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 4 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 4 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 4 | our $VERSION = '0.03'; | |||||||||
| 8 | |||||||||||
| 9 | 5 | ▶ | sub new ($$) { | ||||||||
|
Subroutine
new: called CC=3 SCAR=11.1
Pod
documented
| |||||||||||
| 10 | 5 | ▶ | my $class = ref $_[0] ? ref shift : shift; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 11 | 5 | ▶ | my $now = @_ ? shift : 0; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 12 | 5 | bless { | |||||||||
| 13 | now => $now, | ||||||||||
| 14 | }, $class; | ||||||||||
| 15 | } | ||||||||||
| 16 | |||||||||||
| 17 | 118 | ▶ | sub now ($) { | ||||||||
|
Subroutine
now: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 18 | 118 | $_[0]->{now}; | |||||||||
| 19 | } | ||||||||||
| 20 | |||||||||||
| 21 | 29 | ▶ | sub push_to ($$) { | ||||||||
|
Subroutine
push_to: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 22 | 29 | my ($self, $time) = @_; | |||||||||
| 23 | 29 | ▶ | if ($time < $self->now) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 24 | 1 | carp "error: Can't push your time back, sir"; | |||||||||
| 25 | 1 | return 0; | |||||||||
| 26 | } | ||||||||||
| 27 | 28 | $self->{now} = $time; | |||||||||
| 28 | 28 | return 1; | |||||||||
| 29 | } | ||||||||||
| 30 | |||||||||||
| 31 | 5 | ▶ | sub reset ($) { | ||||||||
|
Subroutine
reset: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 32 | 5 | $_[0]->{now} = 0; | |||||||||
| 33 | } | ||||||||||
| 34 | |||||||||||
| 35 | 4 | 1; | |||||||||
| 36 | __END__ | ||||||||||