--- trunk/Estraier.pm 2006/01/04 14:48:11 6 +++ trunk/Estraier.pm 2006/01/04 15:04:58 8 @@ -43,6 +43,8 @@ package Search::Estraier::Document; +use Carp qw/confess/; + =head1 Search::Estraier::Document Document for HyperEstraier @@ -81,8 +83,10 @@ my $attrs = {@_}; while (my ($name, $value) = each %{ $attrs }) { - push @{ $self->{attrs}->{_s($name)} }, _s($value); + $self->{attrs}->{_s($name)} = _s($value); } + + return 1; } @@ -132,6 +136,36 @@ return $self->{id}; } +=head2 attr_names + +Get a list of attribute names of a document object. + + my @attrs = $doc->attr_names; + +=cut + +sub attr_names { + my $self = shift; + confess "attr_names return array, not scalar" if (! wantarray); + return sort keys %{ $self->{attrs} }; +} + + +=head2 attr + +Get the value of an attribute. + + my $value = $doc->attr( 'attribute' ); + +=cut + +sub attr { + my $self = shift; + my $name = shift; + + return $self->{'attrs'}->{ $name }; +} + =head2 dump_draft print $doc->dump_draft;