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' ); |
73 |
my $attrs = {@_}; |
my $attrs = {@_}; |
74 |
|
|
75 |
while (my ($name, $value) = each %{ $attrs }) { |
while (my ($name, $value) = each %{ $attrs }) { |
76 |
$name =~ s/\s\s+/ /gs; |
push @{$self->{attrs}->{_s($name)}}, _s($value); |
|
$value =~ s/\s\s+/ /gs; |
|
|
push @{$self->{$name}}, $value; |
|
77 |
} |
} |
78 |
} |
} |
79 |
|
|
80 |
|
=head2 delete |
81 |
|
|
82 |
|
Empty document object |
83 |
|
|
84 |
|
$doc->delete; |
85 |
|
|
86 |
|
=cut |
87 |
|
|
88 |
|
sub delete { |
89 |
|
my $self = shift; |
90 |
|
|
91 |
|
delete($self->{attrs}); |
92 |
|
|
93 |
|
return 1; |
94 |
|
} |
95 |
|
|
96 |
|
|
97 |
|
=head2 _s |
98 |
|
|
99 |
|
Remove multiple whitespaces from string, as well as whitespaces at beginning or end |
100 |
|
|
101 |
|
my $text = _s(" this is a text "); |
102 |
|
$text = 'this is a text'; |
103 |
|
|
104 |
|
=cut |
105 |
|
|
106 |
|
sub _s { |
107 |
|
my $text = shift || return; |
108 |
|
$text =~ s/\s\s+/ /gs; |
109 |
|
$text =~ s/^\s+//; |
110 |
|
$text =~ s/\s+$//; |
111 |
|
return $text; |
112 |
|
} |
113 |
|
|
114 |
|
|
115 |
|
|
116 |
package Search::Estraier::Master; |
package Search::Estraier::Master; |