WWW-Mixi-OO
view release on metacpan or search on metacpan
lib/WWW/Mixi/OO/TableListPage.pm view on Meta::CPAN
=head1 INTERNAL METHODS
these methods used from internal (such as subclass).
=over 4
=item parse_table
=item parse_navi
=item parse_body
cached parser methods for _parse_table, _parse_navi, _parse_body.
=cut
__PACKAGE__->mk_cached_parser(qw(table navi body));
=item _parse_table
# subclass
sub _parse_table {
my $this = shift;
return $this->SUPER::_parse_table(@_) if @_ == 1; # overridable
my %options = @_;
$this->SUPER::_parse_table(qr/.../);
}
return main table.
=cut
sub _parse_table {
my $this = shift;
my $part = $this->parse_extract_parts(shift);
return () unless defined $part;
# split to each tables
$this->_split_tables($part);
return $part;
}
=item _split_tables
# subclass
sub _split_tables {
my ($this, $part) = @_;
my @tables = /(...)/g;
# set tables
$this->cache->{tables} = \@tables;
# set indecies to tables...
$this->cache->{indecies}->{title} = 0;
$this->cache->{indecies}->{navi} = 1;
$this->cache->{indecies}->{body} = 2;
}
split main tables to some parts.
=cut
sub _split_tables {
my ($this, $part) = @_;
my $maybe_attrs_regex = $this->regex_parts->{html_maybe_attrs};
my @tables = $this->extract_balanced_html_parts(
element => 'table',
text => $part);
$this->cache->{tables} = \@tables;
$this->cache->{indecies}->{title} = 0;
if (@tables > 2) {
# remove no-need footer
pop(@tables);
$this->cache->{indecies}->{navi} = 1;
$this->cache->{indecies}->{body} = 2;
} else {
$this->cache->{indecies}->{body} = 1;
}
}
=item parse_table_item_with_index
# call from subclass
sub _parse_foo {
my ($this, %options) = @_;
my $part = $this->parse_table_item_with_index(0);
return () unless defined $part;
# ...
return $1;
}
return split part with index. (maybe useless)
=cut
sub parse_table_item_with_index {
my $this = shift;
$this->parse_table;
return $this->cache->{tables}->[shift];
}
=item parse_table_item
# call from subclass
sub _parse_body {
my ($this, %options) = @_;
my $part = $this->parse_table_item('body');
return () unless defined $part;
# ...
return $1;
}
return split part with keyword.
=cut
sub parse_table_item {
my $this = shift;
( run in 0.829 second using v1.01-cache-2.11-cpan-71847e10f99 )