|
|
|
@ -25,6 +25,21 @@ sub log {
|
|
|
|
|
sub parse { return "Unimplemented by subclass"; } |
|
|
|
|
sub build { return "Unimplemented by subclass"; } |
|
|
|
|
|
|
|
|
|
sub from_string { |
|
|
|
|
my ($self, $text) = @_; |
|
|
|
|
my @lines = split /\r?\n/o, $text; |
|
|
|
|
return $self->parse(\@lines); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
sub from_file { |
|
|
|
|
my ($self, $path) = @_; |
|
|
|
|
open my $FH, '<', $path |
|
|
|
|
or return -1; |
|
|
|
|
my @lines = <$FH>; |
|
|
|
|
close $FH; |
|
|
|
|
return $self->parse(\@lines); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
1; |
|
|
|
|
|
|
|
|
|
=pod |
|
|
|
@ -55,6 +70,21 @@ Collected messages can be accessed like this:
|
|
|
|
|
=head C<build> |
|
|
|
|
=head C<parse> |
|
|
|
|
|
|
|
|
|
Stubs for subclasses |
|
|
|
|
Stubs for subclasses. |
|
|
|
|
Should return -1 on error, >= 0 on success (parsed events count). |
|
|
|
|
|
|
|
|
|
=head2 C<from_string> |
|
|
|
|
|
|
|
|
|
my $cnt = $obj->from_string($text); |
|
|
|
|
|
|
|
|
|
Parse subtitle from given string. |
|
|
|
|
Return codes are the same as C<parse> |
|
|
|
|
|
|
|
|
|
=head2 C<from_file> |
|
|
|
|
|
|
|
|
|
my $cnt = $obj->from_file($path); |
|
|
|
|
|
|
|
|
|
Parse subtitle from given file. |
|
|
|
|
Return codes are the same as C<parse> |
|
|
|
|
|
|
|
|
|
=cut |
|
|
|
|