App-LastStats

 view release on metacpan or  search on metacpan

lib/App/LastStats.pm  view on Meta::CPAN

  field $data;
  field @artists;

  field $renderer = {
    text => \&render_text,
    html => \&render_html,
    json => \&render_json,
  };

  method run {
    $self->validate;
    $self->laststats;
    $self->render;
  }

  method validate {
    $period = lc $period;
    $format = lc $format;

    my @valid_periods = qw(overall 7day 1month 3month 6month 12month);
    unless (grep { $_ eq $period } @valid_periods) {
      die "Invalid period: $period\n",
          'Valid periods are: ', join(', ', @valid_periods), "\n";
    }

    unless (exists $renderer->{$format}) {

lib/App/LastStats.pm  view on Meta::CPAN

=head1 DESCRIPTION

App::LastStats is a module that fetches and displays Last.fm statistics for a given user. It allows you to specify the time period, format, and number of artists to display.

=head1 METHODS

=head2 run

Fetches and displays the Last.fm statistics based on the provided options.

=head2 validate

Validates the provided options.

=head2 render_text

Renders the statistics in plain text format.

=head2 render_json

Renders the statistics in JSON format.



( run in 0.560 second using v1.01-cache-2.11-cpan-39bf76dae61 )