|
|
@ -77,6 +77,26 @@ sub set { |
|
|
|
return 1; |
|
|
|
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 { |
|
|
|
sub to_string { |
|
|
|
my ($self) = @_; |
|
|
|
my ($self) = @_; |
|
|
|
my @fields = $self->fields(); |
|
|
|
my @fields = $self->fields(); |
|
|
|