NAME
Sport::Analytics::NHL::Report - Generic class for an NHL report
SYNOPSYS
Generic class for an NHL report
Contains methods common for most (usually HTML) or all NHL reports.
use Sport::Analytics::NHL::Report;
my $report = Sport::Analytics::NHL::Report->new($args);
$report->process();
METHODS
new
-
Common constructor wrapper. Assigns the report plugin, and initializes the report object. For a json report usually an overloaded constructor is required. For an HTML report, the generic html_new (q.v.) method is usually sufficient. Arguments: the arguments hashref * file: the file with the report OR * data: the scalar with the report BUT NOT BOTH * type: explicitly specify the type of the report Returns: the blessed object of one of the Report's Plugins.
The object represents an NHL game.
html_new
-
Specific constructor for the HTML reports. Parses the HTML using HTML::TreeBuilder, immediately storing the tree as another storable (.tree) for re-use. The tree resides in $obj->{html}. The raw HTML is stored in $obj->{source}. The type of the report is set in $obj->{type}. Arguments: see new() (q.v.) Returns: the blessed object.
convert_time_date
-
Converts the NHL HTML header date strings of start and end of the game into $obj->{start_ts} and $obj->{end_ts} timestamps and sets the object's time zone in $obj->{tz} and the month in $obj->{month}. Arguments: whether to force US date parsing or not. Note: uses $self->{date} anf $self->{time} from get_header() (q.v.) Returns: void. Sets object fields
force_decision
-
Forces a decision setting on a goaltender in case the reports miss on it explicitly. Usually happens in tied games. Arguments: the team to force the decision Returns: void. Sets a team's goaltender with the decision.
get_header
-
Gets the HTML node path for the HTML report header (teams, score, location, attendance etc.) Arguments: none Returns: void. Sets the path in $obj->{head}
get_sub_tree
-
Gets the node in the HTML Tree as set by a path. Arguments: * flag 0|1 whether the node or its contents are wanted * the walk path to the node as arrayref * optional: the sub tree to walk (or $obj->{html})
normalize
-
A post-process function for the report that should be overloaded.
parse
-
A processing function for the specific report that must be overloaded.
process
-
Read the boxscore: read the header, parse the rest (overloaded), normalize it (may be overloaded), delete the html tree to free the memory and delete the HTML source for the same purpose. Arguments: none Returns: void
read_arena_info
-
Reads the arena information from the game header Arguments: the HTML element with the arena information Returns: void. Sets the arena and the attendance in the object.
read_date_info
-
Reads the date from the game header Arguments: the HTML element with the date information Returns: void. Sets the date in the object. Implies calling convert_date_time (q.v.) later.
read_game_info
-
Reads the NHL id from the game header Arguments: the HTML element with the game id information Returns: void. Sets the nhl season game id in the object.
read_header
-
Parses the header of the HTML report, dispatching the processing of the discovered information elements. Arguments: none Returns: void. Everything is set in the object.
has_html
-
Checks if one of the sources of the boxscore is an HTML report Arguments: none Returns: True|False
read_status
-
Reads the game status block from the game header Arguments: the HTML element with the game status and other information Returns: void. Sets the information in the object.
read_status_info
-
Reads the actual status of the game from the header Arguments: the HTML element with the status information Returns: void. Sets the status in the object.
read_team
-
Reads the team information from the game header Arguments: the HTML element with the team information and the index of the team Returns: void. Sets the team information in the object.
read_time_info
-
Reads the time from the game header Arguments: the HTML element with the time information Returns: void. Sets the date in the object. Implies calling convert_date_time (q.v.) later.
set_args
-
Sets the argument for the constructor. Juggles the data, file and type fields. Arguments: the args hashref: * the file to process OR * the scalar with the data to process, BUT NOT BOTH. * the explicit data type setting, optional when 'file' is specified. Returns: void. Updates the args hashref.
set_event_extra_data
-
Sets extra data to already parsed events:
* The file type as event source * The game_id normalized * Bench player in case of bench penalty * Resolves teams to standard 3-letter codes * Converts time to timestamp (ts) * Sets field t for primary event team: 0 for away, 1 for home, -1 - noplay event
Arguments: none Returns: void. Updates the events in the object.
AUTHOR
More Hockey Stats, <contact at morehockeystats.com>
BUGS
Please report any bugs or feature requests to contact at morehockeystats.com
, or through the web interface at https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Sport::Analytics::NHL::Report. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc Sport::Analytics::NHL::Report
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
https://rt.cpan.org/NoAuth/Bugs.html?Dist=Sport::Analytics::NHL::Report
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
https://cpanratings.perl.org/d/Sport::Analytics::NHL::Report
Search CPAN