File Coverage

blib/lib/Device/CableModem/Zoom5341/Get.pm
Criterion Covered Total %
statement 31 31 100.0
branch 13 16 81.2
condition n/a
subroutine 9 9 100.0
pod 0 2 0.0
total 53 58 91.3


line stmt bran cond sub pod time code
1 7     7   34 use strict;
  7         23  
  7         213  
2 7     7   36 use warnings;
  7         12  
  7         156  
3              
4 7     7   31 use Carp;
  7         10  
  7         1292  
5              
6              
7             =head1 NAME
8              
9             Device::CableModem::Zoom5341::Get
10              
11             =head1 NOTA BENE
12              
13             This is part of the guts of Device::CableModem::Zoom5341. If you're
14             reading this, you're either developing the module, writing tests, or
15             coloring outside the lines; consider yourself warned.
16              
17             =cut
18              
19              
20             =head2 ->get_down_stats
21              
22             Return all the downstream stats as a hashref.
23             =cut
24             sub get_down_stats
25             {
26 2     2 0 1023 my $self = shift;
27              
28 2 100       14 $self->parse_conn_stats unless $self->{conn_stats};
29 2 100       210 croak "No downstats" unless $self->{conn_stats}{down};
30 1         4 return $self->{conn_stats}{down};
31             }
32              
33             =head2 ->get_up_stats
34              
35             Return all the upstream stats as a hashref.
36             =cut
37             sub get_up_stats
38             {
39 2     2 0 3298 my $self = shift;
40              
41 2 50       12 $self->parse_conn_stats unless $self->{conn_stats};
42 2 100       95 croak "No upstats" unless $self->{conn_stats}{up};
43 1         3 return $self->{conn_stats}{up};
44             }
45              
46              
47             =head2 ->get_down_freq
48              
49             Return an arrayref of downstream frequencies.
50              
51             =head2 ->get_down_mod
52              
53             Return an arrayref of downstream modulation schemata.
54              
55             =head2 ->get_down_power
56              
57             Return an arrayref of downstream power levels (dBmV).
58              
59             =head2 ->get_down_snr
60              
61             Return an arrayref of downstream SNRs (dB).
62             =cut
63              
64             for my $k (qw(freq mod power snr))
65             {
66 7     7   37 no strict 'refs';
  7         18  
  7         1006  
67             *{"get_down_$k"} = sub {
68 6     6   4842 my $self = shift;
69 6 50       19 $self->parse_conn_stats unless $self->{conn_stats};
70 6 100       125 croak "No down ${k}stats" unless $self->{conn_stats}{down}{$k};
71 5         15 return $self->{conn_stats}{down}{$k};
72             };
73             }
74              
75              
76             =head2 ->get_up_chanid
77              
78             Return an arrayref of upstream channel ids.
79              
80             =head2 ->get_up_freq
81              
82             Return an arrayref of upstream frequencies.
83              
84             =head2 ->get_up_bw
85              
86             Return an arrayref of upstream bandwidths (in the physical sense of the
87             width of the channel, not the logical sense of a data rate).
88              
89             =head2 ->get_up_power
90              
91             Return an arrayref of upstream power levels (dBmV).
92             =cut
93              
94             for my $k (qw(chanid freq bw power))
95             {
96 7     7   52 no strict 'refs';
  7         21  
  7         956  
97             *{"get_up_$k"} = sub {
98 6     6   7590 my $self = shift;
99 6 50       29 $self->parse_conn_stats unless $self->{conn_stats};
100 6 100       104 croak "No up ${k}stats" unless $self->{conn_stats}{up}{$k};
101 5         14 return $self->{conn_stats}{up}{$k};
102             };
103             }
104              
105              
106              
107             1;
108             __END__