X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=lib%2FBit%2FMorseSignals%2FEmitter.pm;h=af654a20587f4b5afe2c939a515eca3b3dd9f5ac;hb=c897b49aebc38815d86d180f6009b3a480d5e907;hp=44fec2401627773a9c817e1af2e4dd6e6087c5aa;hpb=f90efd6aef2e807ed35c07341456ce727d6668bc;p=perl%2Fmodules%2FBit-MorseSignals.git diff --git a/lib/Bit/MorseSignals/Emitter.pm b/lib/Bit/MorseSignals/Emitter.pm index 44fec24..af654a2 100644 --- a/lib/Bit/MorseSignals/Emitter.pm +++ b/lib/Bit/MorseSignals/Emitter.pm @@ -15,15 +15,15 @@ Bit::MorseSignals::Emitter - Base class for Bit::MorseSignals emitters. =head1 VERSION -Version 0.01 +Version 0.06 =cut -our $VERSION = '0.01'; +our $VERSION = '0.06'; =head1 SYNOPSIS - use Bit::MorseSignals; + use Bit::MorseSignals::Emitter; my $deuce = new Bit::MorseSignals::Emitter; $deuce->post("hlagh") for 1 .. 3; @@ -64,13 +64,13 @@ sub _count_bits { =head2 C -L object constructor. Currently does not take any optional argument. +L object constructor. Currently does not take any optional argument. =cut sub new { my $class = shift; - $class = ref $class || $class || return; + return unless $class = ref $class || $class; croak 'Optional arguments must be passed as key => value pairs' if @_ % 2; my %opts = @_; my $self = { @@ -81,7 +81,7 @@ sub new { return $self; } -=head2 C<< post $msg, [ type => $type ] >> +=head2 C<< 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 @@ -128,8 +128,8 @@ sub post { $self->{state} = 2; my $head = ''; - vec($head, 0, 1) = ($type & 2) >> 1; - vec($head, 1, 1) = ($type & 1); + vec($head, 0, 1) = ($type & 1); + vec($head, 1, 1) = ($type & 2) >> 1; vec($head, 2, 1) = 0; my $hlen = 3; @@ -176,6 +176,30 @@ sub pop { return $bit; } +=head2 C + +The length of the currently posted message. + +=cut + +sub len { + my ($self) = @_; + _check_self($self); + return $self->{len}; +} + +=head2 C + +The number of bits that have already been sent for the current message. + +=cut + +sub pos { + my ($self) = @_; + _check_self($self); + return $self->{pos}; +} + =head2 C Cancels the current transfer, but does not empty the queue. @@ -241,9 +265,9 @@ L, L. =head1 AUTHOR -Vincent Pit, C<< >> +Vincent Pit, C<< >>, L. -You can contact me by mail or on #perl @ FreeNode (vincent or Prof_Vince). +You can contact me by mail or on C (vincent). =head1 BUGS @@ -255,6 +279,8 @@ You can find documentation for this module with the perldoc command. perldoc Bit::MorseSignals::Emitter +Tests code coverage report is available at L. + =head1 COPYRIGHT & LICENSE Copyright 2008 Vincent Pit, all rights reserved.