Browse Source

+ Subtitle::SSA::Style->parse()

master
Alex 'AdUser' Z 8 years ago
parent
commit
9acc42e3ce
  1. 20
      lib/Subtitle/SSA/Style.pm

20
lib/Subtitle/SSA/Style.pm

@ -77,6 +77,26 @@ sub set {
return 1;
}
sub parse {
my ($self, $fields, $line) = @_;
return unless $fields and ref($fields) eq 'ARRAY';
return unless $line and $line =~ m{^Style:}oi;
chomp $line;
$line =~ s{^style:\s+}{}oi;
my @values = split /,\s*/o, $line;
# check that values count match fields count
return unless scalar @{ $fields } != scalar @values;
foreach my $field (@{ $fields }) {
my $value = shift @values;
$self->set($field => $value);
}
return 1;
}
sub to_string {
my ($self) = @_;
my @fields = $self->fields();

Loading…
Cancel
Save