43 |
|
|
44 |
package Search::Estraier::Document; |
package Search::Estraier::Document; |
45 |
|
|
46 |
|
use Carp qw/confess/; |
47 |
|
|
48 |
=head1 Search::Estraier::Document |
=head1 Search::Estraier::Document |
49 |
|
|
50 |
Document for HyperEstraier |
Document for HyperEstraier |
60 |
my $self = {@_}; |
my $self = {@_}; |
61 |
bless($self, $class); |
bless($self, $class); |
62 |
|
|
63 |
|
$self->{id} = -1; |
64 |
|
|
65 |
$self ? return $self : return undef; |
$self ? return $self : return undef; |
66 |
} |
} |
67 |
|
|
68 |
|
|
69 |
=head2 add_attr |
=head2 add_attr |
70 |
|
|
71 |
|
Add an attribute. |
72 |
|
|
73 |
$doc->add_attr( name => 'value' ); |
$doc->add_attr( name => 'value' ); |
74 |
|
|
75 |
B<FIXME>: delete attribute using |
B<FIXME>: delete attribute using |
90 |
|
|
91 |
=head2 add_text |
=head2 add_text |
92 |
|
|
93 |
|
Add a sentence of text. |
94 |
|
|
95 |
$doc->add_text('this is example text to display'); |
$doc->add_text('this is example text to display'); |
96 |
|
|
97 |
=cut |
=cut |
107 |
|
|
108 |
=head2 add_hidden_text |
=head2 add_hidden_text |
109 |
|
|
110 |
|
Add a hidden sentence. |
111 |
|
|
112 |
$doc->add_hidden_text('this is example text just for search'); |
$doc->add_hidden_text('this is example text just for search'); |
113 |
|
|
114 |
=cut |
=cut |
121 |
push @{ $self->{htexts} }, _s($text); |
push @{ $self->{htexts} }, _s($text); |
122 |
} |
} |
123 |
|
|
124 |
|
=head2 id |
125 |
|
|
126 |
|
Get the ID number of document. If the object has never been registred, C<-1> is returned. |
127 |
|
|
128 |
|
print $doc->id; |
129 |
|
|
130 |
|
=cut |
131 |
|
|
132 |
|
sub id { |
133 |
|
my $self = shift; |
134 |
|
return $self->{id}; |
135 |
|
} |
136 |
|
|
137 |
|
=head2 attr_names |
138 |
|
|
139 |
|
Get a list of attribute names of a document object. |
140 |
|
|
141 |
|
my @attrs = $doc->attr_names; |
142 |
|
|
143 |
|
=cut |
144 |
|
|
145 |
|
sub attr_names { |
146 |
|
my $self = shift; |
147 |
|
confess "attr_names return array, not scalar" if (! wantarray); |
148 |
|
return sort keys %{ $self->{attrs} }; |
149 |
|
} |
150 |
|
|
151 |
=head2 dump_draft |
=head2 dump_draft |
152 |
|
|
153 |
print $doc->dump_draft; |
print $doc->dump_draft; |