--- trunk/Estraier.pm 2006/01/04 22:48:29 18 +++ trunk/Estraier.pm 2006/01/05 13:55:06 20 @@ -324,6 +324,9 @@ my $self = {}; bless($self, $class); + $self->{max} = -1; + $self->{options} = 0; + $self ? return $self : return undef; } @@ -415,6 +418,100 @@ return $self->{phrase}; } +=head2 order + +Return search result order. + + print $cond->order; + +=cut + +sub order { + my $self = shift; + return $self->{order}; +} + +=head2 attrs + +Return search result attrs. + + my @cond_attrs = $cond->attrs; + +=cut + +sub attrs { + my $self = shift; + #croak "attrs return array, not scalar" if (! wantarray); + return @{ $self->{attrs} }; +} + +=head2 max + +Return maximum number of results. + + print $cond->max; + +C<-1> is returned for unitialized value, C<0> is unlimited. + +=cut + +sub max { + my $self = shift; + return $self->{max}; +} + +=head2 options + +Return options for this condition. + + print $cond->options; + +Options are returned in numerical form. + +=cut + +sub options { + my $self = shift; + return $self->{options}; +} + + +package Search::Estraier::ResultDocument; + +use Carp qw/confess croak/; + +use Search::Estraier; +our @ISA = qw/Search::Estraier/; + +=head1 Search::Estraier::ResultDocument + +=head2 new + + my $doc = new Search::HyperEstraier::ResultDocument( + uri => 'http://localhost/document/uri/42', + attrs => { + foo => 1, + bar => 2, + }, + snippet => 'this is a text of snippet' + keywords => 'this\tare\tkeywords' + ); + +=cut + +sub new { + my $class = shift; + my $self = {@_}; + bless($self, $class); + + foreach my $f (qw/uri attrs snippet keywords/) { + croak "missing $f for ResultDocument" unless defined($self->{$f}); + } + + $self ? return $self : return undef; +} + + package Search::Estraier::Master;