Browse Source

+ Subtitle::Event

master
Alex 'AdUser' Z 6 years ago
parent
commit
cab4bc2500
  1. 43
      lib/Subtitle/Event.pm
  2. 19
      t/event.t

43
lib/Subtitle/Event.pm

@ -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

19
t/event.t

@ -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…
Cancel
Save