/[Search-Estraier]/trunk/Estraier.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/Estraier.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 15 by dpavlin, Wed Jan 4 22:24:57 2006 UTC revision 19 by dpavlin, Wed Jan 4 23:10:48 2006 UTC
# Line 306  sub delete { Line 306  sub delete {
306    
307  package Search::Estraier::Condition;  package Search::Estraier::Condition;
308    
309    use Carp qw/confess croak/;
310    
311  use Search::Estraier;  use Search::Estraier;
312  our @ISA = qw/Search::Estraier/;  our @ISA = qw/Search::Estraier/;
313    
314    =head1 Search::Estraier::Condition
315    
316    =head2 new
317    
318      my $cond = new Search::HyperEstraier::Condition;
319    
320    =cut
321    
322    sub new {
323            my $class = shift;
324            my $self = {};
325            bless($self, $class);
326    
327            $self->{max} = -1;
328            $self->{options} = 0;
329    
330            $self ? return $self : return undef;
331    }
332    
333    =head2 set_phrase
334    
335      $cond->set_phrase('search phrase');
336    
337    =cut
338    
339    sub set_phrase {
340            my $self = shift;
341            $self->{phrase} = $self->_s( shift );
342    }
343    
344    =head2 add_attr
345    
346      $cond->add_attr('@URI STRINC /~dpavlin/');
347    
348    =cut
349    
350    sub add_attr {
351            my $self = shift;
352            my $attr = shift || return;
353            push @{ $self->{attrs} }, $self->_s( $attr );
354    }
355    
356    =head2 set_order
357    
358      $cond->set_order('@mdate NUMD');
359    
360    =cut
361    
362    sub set_order {
363            my $self = shift;
364            $self->{order} = shift;
365    }
366    
367    =head2 set_max
368    
369      $cond->set_max(42);
370    
371    =cut
372    
373    sub set_max {
374            my $self = shift;
375            my $max = shift;
376            croak "set_max needs number" unless ($max =~ m/^\d+$/);
377            $self->{max} = $max;
378    }
379    
380    =head2 set_options
381    
382      $cond->set_options( SURE => 1 );
383    
384    =cut
385    
386  my $options = {  my $options = {
387          # check N-gram keys skipping by three          # check N-gram keys skipping by three
388          SURE => 1 << 0,          SURE => 1 << 0,
# Line 324  my $options = { Line 398  my $options = {
398          SIMPLE => 1 << 10,          SIMPLE => 1 << 10,
399  };  };
400    
401  =head1 Search::Estraier::Condition  sub set_options {
402            my $self = shift;
403            my $option = shift;
404            confess "unknown option" unless ($options->{$option});
405            $self->{options} ||= $options->{$option};
406    }
407    
408  =head2 new  =head2 phrase
409    
410    my $cond = new Search::HyperEstraier::Condition;  Return search phrase.
411    
412      print $cond->phrase;
413    
414  =cut  =cut
415    
416  sub new {  sub phrase {
417          my $class = shift;          my $self = shift;
418          my $self = {};          return $self->{phrase};
419          bless($self, $class);  }
420    
421          $self ? return $self : return undef;  =head2 order
422    
423    Return search result order.
424    
425      print $cond->order;
426    
427    =cut
428    
429    sub order {
430            my $self = shift;
431            return $self->{order};
432    }
433    
434    =head2 attrs
435    
436    Return search result attrs.
437    
438      my @cond_attrs = $cond->attrs;
439    
440    =cut
441    
442    sub attrs {
443            my $self = shift;
444            #croak "attrs return array, not scalar" if (! wantarray);
445            return @{ $self->{attrs} };
446    }
447    
448    =head2 max
449    
450    Return maximum number of results.
451    
452      print $cond->max;
453    
454    C<-1> is returned for unitialized value, C<0> is unlimited.
455    
456    =cut
457    
458    sub max {
459            my $self = shift;
460            return $self->{max};
461    }
462    
463    =head2 options
464    
465    Return options for this condition.
466    
467      print $cond->options;
468    
469    Options are returned in numerical form.
470    
471    =cut
472    
473    sub options {
474            my $self = shift;
475            return $self->{options};
476  }  }
477    
478    

Legend:
Removed from v.15  
changed lines
  Added in v.19

  ViewVC Help
Powered by ViewVC 1.1.26