WWW::Opentracker::Stats::Mode::Renew - WWW::Opentracker::Stats::Mode::Renew documentation


WWW-Opentracker-Stats documentation Contained in the WWW-Opentracker-Stats distribution.

Index


Code Index:

NAME

Top

WWW::Opentracker::Stats::Mode::Renew

DESCRIPTION

Top

Parses the renew statistics from opentracker.

METHODS

Top

parse_stats

 Args: $self, $payload

Decodes the plain text data retrieved from the renew statistics of opentracker.

The payload looks like this (no indentation): 00 51 01 79 02 69 03 80 ... 41 0 42 1 43 2 44 3

SEE ALSO

Top

WWW::Opentracker::Stats::Mode

AUTHOR

Top

Knut-Olav Hoven, <knutolav@gmail.com>

COPYRIGHT AND LICENSE

Top


WWW-Opentracker-Stats documentation Contained in the WWW-Opentracker-Stats distribution.
package WWW::Opentracker::Stats::Mode::Renew;

use strict;
use warnings;

use parent qw/
    WWW::Opentracker::Stats::Mode
    Class::Accessor::Fast
/;


__PACKAGE__->_format('txt');
__PACKAGE__->_mode('renew');

__PACKAGE__->mk_accessors(qw/_stats/);


sub parse_stats {
    my ($self, $payload) = @_;

    my %stats = ();

    for my $line (split "\n", $payload) {
        chomp $line;

        my ($idx, $count) = $line =~ m{^(\d+) (\d+)}
            or die "Unable to parse line: $line";

        $stats{$idx} = $count;
    }

    return \%stats;
}


1;