The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

WWW::GoKGS::Scraper::TournGames - Games of the KGS tournament

SYNOPSIS

  use WWW::GoKGS::Scraper::TournGames;

  my $tourn_games = WWW::GoKGS::Scraper::TournGames->new;

  my $result = $tourn_games->query(
      id    => 762,
      round => 1,
  );
  # => {
  #     name => 'KGS Meijin Qualifier October 2012',
  #     round => '1',
  #     games => [
  #         {
  #             sgf_uri => 'http://files.gokgs.com/.../foo-bar.sgf',
  #             board_size => 19,
  #             white => {
  #                 name => 'foo',
  #                 rank => '2k',
  #             ],
  #             black => {
  #                 name => 'bar',
  #                 rank => '2k',
  #             },
  #         },
  #     ],
  #     links => {
  #         entrants => [
  #             {
  #                 sort_by => 'name',
  #                 uri     => 'http://www.gokgs.com/tournEntrants.jsp?id=762&sort=n',
  #             },
  #             ...
  #         ],
  #         rounds => [
  #             {
  #                 round      => 1,
  #                 start_time => '10/27/12 4:05 PM',
  #                 end_time   => '10/27/12 6:35 PM',
  #                 uri        => 'http://www.gokgs.com/tournGames.jsp?id=762&round=1',
  #             },
  #             ...
  #         ],
  #     },
  # }

DESCRIPTION

This class inherits from WWW::GoKGS::Scraper.

ATTRIBUTES

$URI = $tuorn_games->base_uri

Defaults to http://www.gokgs.com/tournGames.jsp. This attribute is read-only.

$UserAgent = $tourn_games->user_agent
$tourn_games->user_agent( LWP::UserAgent->new(...) )

Can be used to get or set an LWP::UserAgent object which is used to GET the requested resource. Defaults to the LWP::UserAgent object shared by Web::Scraper users ($Web::Scraper::UserAgent).

$CodeRef = $tourn_games->date_filter
$tourn_games->date_filter( sub { my $date = shift; ... } )

Can be used to get or set a date filter. Defaults to an anonymous subref which just returns the given argument (sub { $_[0] }). The callback is called with a date string such as 2014-05-17T19:05Z. The return value is used as the filtered value.

  use Time::Piece qw/gmtime/;

  $tourn_games->date_filter(sub {
      my $date = shift; # => "2014-05-17T19:05Z"
      gmtime->strptime( $date, '%Y-%m-%dT%H:%MZ' );
  });
$CodeRef = $tourn_games->result_filter
$tourn_games->result_filter( sub { my $result = shift; ... } )

Can be used to get or set a game result filter. Defaults to an anonymous subref which just returns the given argument (sub { $_[0] }). The callback is called with a game result string such as B+Resign. The return value is used as the filtered value.

  $tourn_games->result_filter(sub {
      my $result = shift;

      # I prefer "B+R" to "B+Resign", 
      # while both of them are valid SGF-compatible format
      return 'B+R' if $result eq 'B+Resign';
      ...

      $result;
  });

METHODS

$tourn_games->scrape
$tourn_games->query

SEE ALSO

WWW::GoKGS

AUTHOR

Ryo Anazawa (anazawa@cpan.org)

LICENSE

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.