blib/lib/Net/PulseMeter/Sensor/Counter.pm | |||
---|---|---|---|
Criterion | Covered | Total | % |
statement | 14 | 14 | 100.0 |
branch | n/a | ||
condition | n/a | ||
subroutine | 6 | 6 | 100.0 |
pod | 0 | 3 | 0.0 |
total | 20 | 23 | 86.9 |
line | stmt | bran | cond | sub | pod | time | code |
---|---|---|---|---|---|---|---|
1 | package Net::PulseMeter::Sensor::Counter; | ||||||
2 | 3 | 3 | 626 | use strict; | |||
3 | 20 | ||||||
3 | 95 | ||||||
3 | 3 | 3 | 20 | use warnings 'all'; | |||
3 | 4 | ||||||
3 | 96 | ||||||
4 | |||||||
5 | 3 | 3 | 15 | use base qw/Net::PulseMeter::Sensor::Base/; | |||
3 | 4 | ||||||
3 | 593 | ||||||
6 | |||||||
7 | sub event { | ||||||
8 | 4 | 4 | 0 | 7 | my ($self, $value) = @_; | ||
9 | 4 | 15 | $self->r->incrby($self->value_key, $value); | ||||
10 | } | ||||||
11 | |||||||
12 | 2 | 2 | 0 | 6 | sub incr { shift->event(1) } | ||
13 | |||||||
14 | sub value_key { | ||||||
15 | 18 | 18 | 0 | 528 | my $self = shift; | ||
16 | 18 | 76 | sprintf("pulse_meter:value:%s", $self->name); | ||||
17 | } | ||||||
18 | |||||||
19 | 1; |