| 1 | package MARC::Moose::Writer; | ||
| 2 | # ABSTRACT: A Moose::Role to write somewhere MARC::Moose records | ||
| 3 | 1 | $MARC::Moose::Writer::VERSION = '1.0.46'; | |
| 4 | 1 | ▶ | use Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | 1 | with 'MooseX::RW::Writer'; | |
| 7 | |||
| 8 | |||
| 9 | |||
| 10 | |||
| 11 | has formater => ( | ||
| 12 | is => 'rw', | ||
| 13 | isa => 'MARC::Moose::Formater', | ||
| 14 | 0 | ▶ | default => sub { MARC::Moose::Formater::Text->new() } |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 15 | 1 | ); | |
| 16 | |||
| 17 | |||
| 18 | |||
| 19 | 1 | has fh => ( is => 'rw' ); | |
| 20 | |||
| 21 | |||
| 22 | |||
| 23 | sub begin { | ||
| 24 | 0 | ▶ | my $self = shift; |
|
Subroutine
begin: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 25 | 0 | my $fh = $self->fh; | |
| 26 | 0 | print $fh $self->formater->begin(); | |
| 27 | }; | ||
| 28 | |||
| 29 | |||
| 30 | |||
| 31 | sub end { | ||
| 32 | 0 | ▶ | my $self = shift; |
|
Subroutine
end: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 33 | 0 | my $fh = $self->fh; | |
| 34 | 0 | print $fh $self->formater->end(); | |
| 35 | }; | ||
| 36 | |||
| 37 | |||
| 38 | |||
| 39 | sub write { | ||
| 40 | 0 | ▶ | my ($self, $record) = @_; |
|
Subroutine
write: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 41 | 0 | my $fh = $self->fh; | |
| 42 | 0 | print $fh $self->formater->format($record); | |
| 43 | 0 | $self->count( $self->count + 1); | |
| 44 | } | ||
| 45 | |||
| 46 | |||
| 47 | 1 | 1; | |
| 48 | |||
| 49 | __END__ | ||
| 50 | |||
| 51 | =pod | ||
| 52 | |||
| 53 | =encoding UTF-8 | ||
| 54 | |||
| 55 | =head1 NAME | ||
| 56 | |||
| 57 | MARC::Moose::Writer - A Moose::Role to write somewhere MARC::Moose records | ||
| 58 | |||
| 59 | =head1 VERSION | ||
| 60 | |||
| 61 | version 1.0.46 | ||
| 62 | |||
| 63 | =head1 ATTRIBUTES | ||
| 64 | |||
| 65 | =head2 formater | ||
| 66 | |||
| 67 | A L<MARC::Moose::Formater> to be used to format records to write. By defaut, | ||
| 68 | it's a L<MARC::Moose::Formater::Text> formater. | ||
| 69 | |||
| 70 | =head2 fh | ||
| 71 | |||
| 72 | A file handle to which writing records. This can be a string with: | ||
| 73 | |||
| 74 | open my $fh, ">", \$str; | ||
| 75 | |||
| 76 | =head1 METHODS | ||
| 77 | |||
| 78 | =head2 begin | ||
| 79 | |||
| 80 | Method to be call before beginning writing record with L<write> method. By | ||
| 81 | default, this is just a call to the formater C<begin> method. | ||
| 82 | |||
| 83 | =head2 end | ||
| 84 | |||
| 85 | Method to be call at the end of the writing process, afet the last record has | ||
| 86 | been written, the last call to L<write>. By default, this is just a call to the | ||
| 87 | formater C<end> method. | ||
| 88 | |||
| 89 | =head2 write($record) | ||
| 90 | |||
| 91 | Write L<MARC::Moose::Record> $record into whatever data stream, a file, a | ||
| 92 | socket, etc. It uses the L<formater> to format the record. In this base class, | ||
| 93 | the record is printed on STDOUT. | ||
| 94 | |||
| 95 | =head1 AUTHOR | ||
| 96 | |||
| 97 | Frédéric Demians <f.demians@tamil.fr> | ||
| 98 | |||
| 99 | =head1 COPYRIGHT AND LICENSE | ||
| 100 | |||
| 101 | This software is copyright (c) 2022 by Frédéric Demians. | ||
| 102 | |||
| 103 | This is free software; you can redistribute it and/or modify it under | ||
| 104 | the same terms as the Perl 5 programming language system itself. | ||
| 105 | |||
| 106 | =cut | ||