X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=lib%2FBit%2FMorseSignals%2FEmitter.pm;h=ee7118e0a77790ee700f18c6c5029d4529e204fa;hb=4edcf469e09bb23c40cdba77f905ce341b0ce771;hp=54203afccc5f8682bb964697f1ccf5d3b605cda8;hpb=72cae6c1d4dcdbfe9b437dc8a8949ce282bffeb0;p=perl%2Fmodules%2FBit-MorseSignals.git diff --git a/lib/Bit/MorseSignals/Emitter.pm b/lib/Bit/MorseSignals/Emitter.pm index 54203af..ee7118e 100644 --- a/lib/Bit/MorseSignals/Emitter.pm +++ b/lib/Bit/MorseSignals/Emitter.pm @@ -3,11 +3,11 @@ package Bit::MorseSignals::Emitter; use strict; use warnings; -use Carp qw/croak/; -use Encode qw/encode_utf8 is_utf8/; -use Storable qw/freeze/; +use Carp qw; +use Encode qw; +use Storable qw; -use Bit::MorseSignals qw/:consts/; +use Bit::MorseSignals qw<:consts>; =head1 NAME @@ -15,11 +15,11 @@ Bit::MorseSignals::Emitter - Base class for Bit::MorseSignals emitters. =head1 VERSION -Version 0.06 +Version 0.08 =cut -our $VERSION = '0.06'; +our $VERSION = '0.08'; =head1 SYNOPSIS @@ -33,9 +33,11 @@ our $VERSION = '0.06'; =head1 DESCRIPTION -Base class for L emitters. Please refer to this module for more general information about the protocol. +Base class for L emitters. +Please refer to this module for more general information about the protocol. -The emitter object enqueues messages and prepares them one by one into L packets. It gives then back the bits of the packet in the order they should be sent. +The emitter object enqueues messages and prepares them one by one into L packets. +It gives then back the bits of the packet in the order they should be sent. =cut @@ -64,7 +66,10 @@ sub _count_bits { =head2 C -L object constructor. Currently does not take any optional argument. + my $bme = Bit::MorseSignals::Emitter->new; + +L object constructor. +Currently does not take any optional argument. =cut @@ -81,9 +86,12 @@ sub new { return $self; } -=head2 C<< post $msg, < type => $type > >> +=head2 C + + $bme->post($msg, type => $type); -Adds C<$msg> to the message queue and, if no other message is currently processed, dequeue the oldest item and prepare it. The type is automatically chosen, but you may want to try to force it with the C option : C<$type> is then one of the C constants listed in L +Adds C<$msg> to the message queue and, if no other message is currently processed, dequeue the oldest item and prepare it. +The type is automatically chosen, but you may want to try to force it with the C option : C<$type> is then one of the C constants listed in L =cut @@ -102,7 +110,7 @@ sub post { # BM_DATA_{PLAIN, UTF8, STORABLE} $type = BM_DATA_AUTO unless defined $type and exists $manglers[$type]; if (ref $msg) { - return if { map { $_ => 1 } qw/CODE GLOB/ }->{ref $msg}; + return if { map { $_ => 1 } qw }->{ref $msg}; $type = BM_DATA_STORABLE; } elsif ($type == BM_DATA_AUTO) { $type = is_utf8($msg) ? BM_DATA_UTF8 : BM_DATA_PLAIN; @@ -158,7 +166,10 @@ sub post { =head2 C -If a message is being processed, pops the next bit in the packet. When the message is over, the next in the queue is immediatly prepared and the first bit of the new packet is given back. If the queue is empty, C is returned. You may want to use this method with the idiom : +If a message is being processed, pops the next bit in the packet. +When the message is over, the next in the queue is immediatly prepared and the first bit of the new packet is given back. +If the queue is empty, C is returned. +You may want to use this method with the idiom : while (defined(my $bit = $deuce->pop)) { ... @@ -210,7 +221,7 @@ sub reset { my ($self) = @_; _check_self($self); $self->{state} = @{$self->{queue}} > 0; - @{$self}{qw/buf len pos/} = (); + @{$self}{qw} = (); return $self; } @@ -271,7 +282,8 @@ You can contact me by mail or on C (vincent). =head1 BUGS -Please report any bugs or feature requests to C, or through the web interface at L. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. +Please report any bugs or feature requests to C, or through the web interface at L. +I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. =head1 SUPPORT