--- trunk/Estraier.pm 2006/01/04 13:13:06 3 +++ trunk/Estraier.pm 2006/01/04 13:33:07 4 @@ -61,6 +61,7 @@ $self ? return $self : return undef; } + =head2 add_attr $doc->add_attr( name => 'value' ); @@ -72,12 +73,44 @@ my $attrs = {@_}; while (my ($name, $value) = each %{ $attrs }) { - $name =~ s/\s\s+/ /gs; - $value =~ s/\s\s+/ /gs; - push @{$self->{$name}}, $value; + push @{$self->{attrs}->{_s($name)}}, _s($value); } } +=head2 delete + +Empty document object + + $doc->delete; + +=cut + +sub delete { + my $self = shift; + + delete($self->{attrs}); + + return 1; +} + + +=head2 _s + +Remove multiple whitespaces from string, as well as whitespaces at beginning or end + + my $text = _s(" this is a text "); + $text = 'this is a text'; + +=cut + +sub _s { + my $text = shift || return; + $text =~ s/\s\s+/ /gs; + $text =~ s/^\s+//; + $text =~ s/\s+$//; + return $text; +} + package Search::Estraier::Master;