| 1 | package Message::Passing::Output::IO::Handle; | ||
| 2 | 1 | ▶ | use Moo; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | #use Moose::Util::TypeConstraints; | ||
| 4 | 1 | ▶ | use namespace::clean -except => 'meta'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | 1 | with 'Message::Passing::Role::Output'; | |
| 7 | |||
| 8 | 1 | has fh => ( | |
| 9 | # isa => duck_type([qw/ print /]), | ||
| 10 | is => 'ro', | ||
| 11 | required => 1, | ||
| 12 | ); | ||
| 13 | |||
| 14 | has append => ( | ||
| 15 | is => 'ro', | ||
| 16 | 0 | ▶ | default => sub { "\n" }, |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 17 | 1 | ); | |
| 18 | |||
| 19 | sub consume { | ||
| 20 | 0 | ▶ | my $self = shift; |
|
Subroutine
consume: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 21 | 0 | $self->fh->print(shift() . $self->append); | |
| 22 | } | ||
| 23 | |||
| 24 | |||
| 25 | 1 | 1; | |
| 26 | |||
| 27 | =head1 NAME | ||
| 28 | |||
| 29 | Message::Passing::Output::IO::Handle - output to an IO handle | ||
| 30 | |||
| 31 | =head1 SYNOPSIS | ||
| 32 | |||
| 33 | my $out = Message::Passing::Output::IO::Handle->new( | ||
| 34 | fh => \*STDOUT, | ||
| 35 | append => "\n", | ||
| 36 | ); | ||
| 37 | # $out will now act like Message::Passing::Output::STDOUT | ||
| 38 | |||
| 39 | =head1 DESCRIPTION | ||
| 40 | |||
| 41 | Output messages to an L<IO::Handle> like handle, i.e. any class | ||
| 42 | which implements a C<< ->print($stuff) >> method. | ||
| 43 | |||
| 44 | =head1 ATTRIBUTES | ||
| 45 | |||
| 46 | =head2 fh | ||
| 47 | |||
| 48 | The file handle object. Required. | ||
| 49 | |||
| 50 | =head2 append | ||
| 51 | |||
| 52 | String to append to each message. Defaults to "\n" | ||
| 53 | |||
| 54 | =head1 METHODS | ||
| 55 | |||
| 56 | =head2 consume | ||
| 57 | |||
| 58 | Consumes a message by printing it, followed by \n | ||
| 59 | |||
| 60 | =head1 SEE ALSO | ||
| 61 | |||
| 62 | L<Message::Passing> | ||
| 63 | |||
| 64 | =head1 SPONSORSHIP | ||
| 65 | |||
| 66 | This module exists due to the wonderful people at Suretec Systems Ltd. | ||
| 67 | <http://www.suretecsystems.com/> who sponsored its development for its | ||
| 68 | VoIP division called SureVoIP <http://www.surevoip.co.uk/> for use with | ||
| 69 | the SureVoIP API - | ||
| 70 | <http://www.surevoip.co.uk/support/wiki/api_documentation> | ||
| 71 | |||
| 72 | =head1 AUTHOR, COPYRIGHT AND LICENSE | ||
| 73 | |||
| 74 | See L<Message::Passing>. | ||
| 75 | |||
| 76 | =cut | ||