/[suikacvs]/messaging/manakai/lib/Message/Body/TextPlain.pm
Suika

Diff of /messaging/manakai/lib/Message/Body/TextPlain.pm

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

revision 1.1 by wakaba, Thu Mar 21 04:20:17 2002 UTC revision 1.2 by wakaba, Mon Mar 25 10:18:35 2002 UTC
# Line 17  $VERSION=do{my @r=(q$Revision$=~/\d+/g); Line 17  $VERSION=do{my @r=(q$Revision$=~/\d+/g);
17  require Message::Header;  require Message::Header;
18  use overload '""' => sub {shift->stringify};  use overload '""' => sub {shift->stringify};
19    
20    %DEFAULT = (
21      encoding_after_encode => '*default',
22      encoding_before_decode        => '*default',
23      hook_encode_string    => #sub {shift; (value => shift, @_)},
24            \&Message::Util::encode_body_string,
25      hook_decode_string    => #sub {shift; (value => shift, @_)},
26            \&Message::Util::decode_body_string,
27    );
28    
29  =head2 Message::Body::TextPlain->new ([%option])  =head2 Message::Body::TextPlain->new ([%option])
30    
31  Returns new Message::Body::TextPlain instance.  Some options can be  Returns new Message::Body::TextPlain instance.  Some options can be
# Line 44  sub parse ($$;%) { Line 53  sub parse ($$;%) {
53    my $self = bless {option => {@_}}, $class;    my $self = bless {option => {@_}}, $class;
54    for (keys %DEFAULT) {$self->{option}->{$_} ||= $DEFAULT{$_}}    for (keys %DEFAULT) {$self->{option}->{$_} ||= $DEFAULT{$_}}
55    $self->header ($self->{option}->{header});    $self->header ($self->{option}->{header});
56    $self->{body} = $body;    my %s = &{$self->{option}->{hook_decode_string}} ($self, $body, type => 'body');
57      $self->{body} = $s{value};
58    $self;    $self;
59  }  }
60    
# Line 92  Returns the C<body> as a string. Line 102  Returns the C<body> as a string.
102  sub stringify ($;%) {  sub stringify ($;%) {
103    my $self = shift;    my $self = shift;
104    my %OPT = @_;    my %OPT = @_;
105    my ($body) = (scalar $self->{body});    my (%e) = &{$self->{option}->{hook_encode_string}} ($self,
106    $body .= "\n" unless $body =~ /\n$/;            $self->{body}, type => 'body');
107    $body;    $e{value} .= "\n" unless $e{value} =~ /\n$/;
108      $e{value};
109  }  }
110  sub as_string ($;%) {shift->stringify (@_)}  sub as_string ($;%) {shift->stringify (@_)}
111    

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24