/[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 8 by dpavlin, Wed Jan 4 15:04:58 2006 UTC revision 9 by dpavlin, Wed Jan 4 15:28:39 2006 UTC
# Line 43  implementation. It also includes methods Line 43  implementation. It also includes methods
43    
44  package Search::Estraier::Document;  package Search::Estraier::Document;
45    
46  use Carp qw/confess/;  use Carp qw/croak confess/;
47    
48  =head1 Search::Estraier::Document  =head1 Search::Estraier::Document
49    
# Line 72  Add an attribute. Line 72  Add an attribute.
72    
73    $doc->add_attr( name => 'value' );    $doc->add_attr( name => 'value' );
74    
75  B<FIXME>: delete attribute using  Delete attribute using
76    
77    $doc->add_attr( name => undef );    $doc->add_attr( name => undef );
78    
# Line 83  sub add_attr { Line 83  sub add_attr {
83          my $attrs = {@_};          my $attrs = {@_};
84    
85          while (my ($name, $value) = each %{ $attrs }) {          while (my ($name, $value) = each %{ $attrs }) {
86                  $self->{attrs}->{_s($name)} = _s($value);                  if (! defined($value)) {
87                            delete( $self->{attrs}->{_s($name)} );
88                    } else {
89                            $self->{attrs}->{_s($name)} = _s($value);
90                    }
91          }          }
92    
93          return 1;          return 1;
# Line 138  sub id { Line 142  sub id {
142    
143  =head2 attr_names  =head2 attr_names
144    
145  Get a list of attribute names of a document object.  Returns array with attribute names from document object.
146    
147    my @attrs = $doc->attr_names;    my @attrs = $doc->attr_names;
148    
# Line 146  Get a list of attribute names of a docum Line 150  Get a list of attribute names of a docum
150    
151  sub attr_names {  sub attr_names {
152          my $self = shift;          my $self = shift;
153          confess "attr_names return array, not scalar" if (! wantarray);          croak "attr_names return array, not scalar" if (! wantarray);
154          return sort keys %{ $self->{attrs} };          return sort keys %{ $self->{attrs} };
155  }  }
156    
157    
158  =head2 attr  =head2 attr
159    
160  Get the value of an attribute.  Returns value of an attribute.
161    
162    my $value = $doc->attr( 'attribute' );    my $value = $doc->attr( 'attribute' );
163    
# Line 166  sub attr { Line 170  sub attr {
170          return $self->{'attrs'}->{ $name };          return $self->{'attrs'}->{ $name };
171  }  }
172    
173    
174    =head2 texts
175    
176    Returns array with text sentences.
177    
178      my @texts = $doc->texts;
179    
180    =cut
181    
182    sub texts {
183            my $self = shift;
184            confess "attr_names return array, not scalar" if (! wantarray);
185            return $self->{dtexts};
186    }
187    
188  =head2 dump_draft  =head2 dump_draft
189    
190    print $doc->dump_draft;    print $doc->dump_draft;
# Line 173  sub attr { Line 192  sub attr {
192  =cut  =cut
193    
194  sub dump_draft {  sub dump_draft {
195            return 'FIXME';
196  }  }
197    
198  =head2 delete  =head2 delete

Legend:
Removed from v.8  
changed lines
  Added in v.9

  ViewVC Help
Powered by ViewVC 1.1.26