/[suikacvs]/messaging/manakai/lib/Message/Field/CSV.pm
Suika

Diff of /messaging/manakai/lib/Message/Field/CSV.pm

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

revision 1.9 by wakaba, Sat May 4 06:03:58 2002 UTC revision 1.10 by wakaba, Wed May 8 09:11:31 2002 UTC
# Line 43  sub _init ($;%) { Line 43  sub _init ($;%) {
43    my $self = shift;    my $self = shift;
44    my %options = @_;    my %options = @_;
45    my %DEFAULT = (    my %DEFAULT = (
46        -_ARRAY_NAME        => 'value',
47      #encoding_after_encode      #encoding_after_encode
48      #encoding_before_decode      #encoding_before_decode
49      -field_name => 'keywords',      -field_name => 'keywords',
# Line 74  sub _init ($;%) { Line 75  sub _init ($;%) {
75       list-owner list- list-post list- list-subscribe list-       list-owner list- list-post list- list-subscribe list-
76       list-unsubscribe list- list-url list- uri list-       list-unsubscribe list- list-url list- uri list-
77       posted-to newsgroups       posted-to newsgroups
78       x-brother x-moe x-boss x-moe x-daughter x-moe x-dearfriend x-moe       x-brother x-moe x-boss x-moe x-classmate x-moe x-daughter x-moe
79         x-dearfriend x-moe
80       x-favoritesong x-moe       x-favoritesong x-moe
81       x-friend x-moe x-me x-moe       x-friend x-moe x-me x-moe
82       x-respect x-moe x-sister x-moe x-son x-moe x-sublimate x-moe x-wife x-moe);       x-respect x-moe x-sister x-moe x-son x-moe x-sublimate x-moe x-wife x-moe);
# Line 202  sub count ($) { Line 204  sub count ($) {
204    
205  Adds (appends) new value(s).  Adds (appends) new value(s).
206    
 =iterm $csv->prepend ($value1, [$value2, $value3,...])  
   
 Prepends new value(s).  
   
207  =cut  =cut
208    
209  sub add ($@) {  sub _add_array_check ($$\%) {
   my $self = shift;  
   push @{$self->{value}}, @_;  
 }  
   
 sub prepend ($@) {  
210    my $self = shift;    my $self = shift;
211    unshift @{$self->{value}}, @_;    my ($value, $option) = @_;
212      my $value_option = {};
213      if (ref $value eq 'ARRAY') {
214        ($value, %$value_option) = @$value;
215      }
216      (1, value => $value);
217  }  }
218    
219  =item $field-body = $csv->stringify ()  =item $field-body = $csv->stringify ()
# Line 236  sub stringify ($;%) { Line 234  sub stringify ($;%) {
234    $option{separator} = $option{separator_long}    $option{separator} = $option{separator_long}
235      if $option{max} >= $option{long_count};      if $option{max} >= $option{long_count};
236    join $option{separator},    join $option{separator},
237      map {      map {$self->_stringify_item ($_, \%option)} @{$self->{value}}[0..$option{max}];
238        if ($option{is_quoted_string}) {  }
239          my %s = &{$self->{option}->{hook_encode_string}} ($self,  *as_string = \&stringify;
240            $_, type => 'phrase');  
241    sub _stringify_item ($$\%) {
242      my $self = shift;
243      my $item = shift;
244      my $option = shift;
245          if ($$option{is_quoted_string}) {
246            my %s = &{$$option{hook_encode_string}} ($self,
247              $item, type => 'phrase');
248          Message::Util::quote_unsafe_string ($s{value},          Message::Util::quote_unsafe_string ($s{value},
249            unsafe => $option{value_unsafe_rule});            unsafe => $$option{value_unsafe_rule});
250        } else {        } else {
251          $_;          $item;
252        }        }
     } @{$self->{value}}[0..$option{max}];  
253  }  }
 *as_string = \&stringify;  
254    
255  =item $option-value = $ua->option ($option-name)  =item $option-value = $ua->option ($option-name)
256    

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.10

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24