Alex 'AdUser' Z
6 years ago
2 changed files with 62 additions and 0 deletions
@ -0,0 +1,43 @@
|
||||
package Subtitle::Event; |
||||
|
||||
use strict; |
||||
use warnings; |
||||
|
||||
sub new { |
||||
my $class = shift; |
||||
my $self = { |
||||
start => 0.0, |
||||
end => 0.0, |
||||
text => '', |
||||
}; |
||||
return bless($self, $class); |
||||
} |
||||
|
||||
sub t_start { |
||||
my ($self, $t) = @_; |
||||
$self->{start} = $t |
||||
if defined $t and $t >= 0.0; |
||||
return $self->{start}; |
||||
} |
||||
sub t_end { |
||||
my ($self, $t) = @_; |
||||
$self->{end} = $t |
||||
if defined $t and $t >= 0.0; |
||||
return $self->{end}; |
||||
} |
||||
sub text { |
||||
my ($self, $t) = @_; |
||||
$self->{text} = $t |
||||
if defined $t; |
||||
return $self->{text}; |
||||
} |
||||
|
||||
1; |
||||
|
||||
=pod |
||||
|
||||
=head1 NAME |
||||
|
||||
Subtitle::Event - base class for subtitle events |
||||
|
||||
=cut |
@ -0,0 +1,19 @@
|
||||
use strict; |
||||
use warnings; |
||||
|
||||
use Test::More tests => 7; |
||||
|
||||
use Subtitle::Event; |
||||
|
||||
my $e = Subtitle::Event->new; |
||||
is(ref $e, 'Subtitle::Event'); |
||||
can_ok($e, qw(new t_start t_end text)); |
||||
|
||||
is($e->t_start, 0.0); |
||||
is($e->t_start(17.2), 17.2); |
||||
is($e->t_start(-5.4), 17.2); |
||||
|
||||
is($e->text, ''); |
||||
is($e->text('test'), 'test'); |
||||
|
||||
1; |
Loading…
Reference in new issue