--- trunk/Estraier.pm 2006/01/04 22:24:57 15 +++ trunk/Estraier.pm 2006/01/04 22:48:29 18 @@ -306,9 +306,80 @@ package Search::Estraier::Condition; +use Carp qw/confess croak/; + use Search::Estraier; our @ISA = qw/Search::Estraier/; +=head1 Search::Estraier::Condition + +=head2 new + + my $cond = new Search::HyperEstraier::Condition; + +=cut + +sub new { + my $class = shift; + my $self = {}; + bless($self, $class); + + $self ? return $self : return undef; +} + +=head2 set_phrase + + $cond->set_phrase('search phrase'); + +=cut + +sub set_phrase { + my $self = shift; + $self->{phrase} = $self->_s( shift ); +} + +=head2 add_attr + + $cond->add_attr('@URI STRINC /~dpavlin/'); + +=cut + +sub add_attr { + my $self = shift; + my $attr = shift || return; + push @{ $self->{attrs} }, $self->_s( $attr ); +} + +=head2 set_order + + $cond->set_order('@mdate NUMD'); + +=cut + +sub set_order { + my $self = shift; + $self->{order} = shift; +} + +=head2 set_max + + $cond->set_max(42); + +=cut + +sub set_max { + my $self = shift; + my $max = shift; + croak "set_max needs number" unless ($max =~ m/^\d+$/); + $self->{max} = $max; +} + +=head2 set_options + + $cond->set_options( SURE => 1 ); + +=cut + my $options = { # check N-gram keys skipping by three SURE => 1 << 0, @@ -324,20 +395,24 @@ SIMPLE => 1 << 10, }; -=head1 Search::Estraier::Condition +sub set_options { + my $self = shift; + my $option = shift; + confess "unknown option" unless ($options->{$option}); + $self->{options} ||= $options->{$option}; +} -=head2 new +=head2 phrase - my $cond = new Search::HyperEstraier::Condition; +Return search phrase. -=cut + print $cond->phrase; -sub new { - my $class = shift; - my $self = {}; - bless($self, $class); +=cut - $self ? return $self : return undef; +sub phrase { + my $self = shift; + return $self->{phrase}; }