/[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 2 by dpavlin, Wed Jan 4 13:11:43 2006 UTC revision 5 by dpavlin, Wed Jan 4 14:38:35 2006 UTC
# Line 61  sub new { Line 61  sub new {
61          $self ? return $self : return undef;          $self ? return $self : return undef;
62  }  }
63    
64    
65  =head2 add_attr  =head2 add_attr
66    
67    $doc->add_attr( name => 'value' );    $doc->add_attr( name => 'value' );
68    
69    B<FIXME>: delete attribute using
70    
71      $doc->add_attr( name => undef );
72    
73  =cut  =cut
74    
75  sub add_attr {  sub add_attr {
# Line 72  sub add_attr { Line 77  sub add_attr {
77          my $attrs = {@_};          my $attrs = {@_};
78    
79          while (my ($name, $value) = each %{ $attrs }) {          while (my ($name, $value) = each %{ $attrs }) {
80                  $name =~ s/\s\s+/ /gs;                  push @{ $self->{attrs}->{_s($name)} }, _s($value);
81                  $value =~ s/\s\s+/ /gs;          }
82                  push @{$self->{$name}}, $value;  }
83    
84    
85    =head2 add_text
86    
87      $doc->add_text('this is example text to display');
88    
89    =cut
90    
91    sub add_text {
92            my $self = shift;
93            my $text = shift;
94            return unless defined($text);
95    
96            push @{ $self->{dtexts} }, _s($text);
97    }
98    
99    
100    =head2 add_hidden_text
101    
102      $doc->add_hidden_text('this is example text just for search');
103    
104    =cut
105    
106    sub add_hidden_text {
107            my $self = shift;
108            my $text = shift;
109            return unless defined($text);
110    
111            push @{ $self->{htexts} }, _s($text);
112    }
113    
114    =head2 dump_draft
115    
116      print $doc->dump_draft;
117    
118    =cut
119    
120    sub dump_draft {
121    }
122    
123    =head2 delete
124    
125    Empty document object
126    
127      $doc->delete;
128    
129    =cut
130    
131    sub delete {
132            my $self = shift;
133    
134            foreach my $data (qw/attrs dtexts stexts/) {
135                    delete($self->{$data});
136          }          }
137    
138            return 1;
139    }
140    
141    
142    =head2 _s
143    
144    Remove multiple whitespaces from string, as well as whitespaces at beginning or end
145    
146     my $text = _s(" this  is a text  ");
147     $text = 'this is a text';
148    
149    =cut
150    
151    sub _s {
152            my $text = shift || return;
153            $text =~ s/\s\s+/ /gs;
154            $text =~ s/^\s+//;
155            $text =~ s/\s+$//;
156            return $text;
157  }  }
158    
159    

Legend:
Removed from v.2  
changed lines
  Added in v.5

  ViewVC Help
Powered by ViewVC 1.1.26