| Image-TextMode documentation | Contained in the Image-TextMode distribution. |
Image::TextMode::Writer - A base class for file writers
This module provides some of the basic functionality for all writer classes.
Creates a new instance.
Writes the contents of $image to $file via the subclass's _write()
method.
Brian Cassidy <bricas@cpan.org>
Copyright 2008-2011 by Brian Cassidy
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| Image-TextMode documentation | Contained in the Image-TextMode distribution. |
package Image::TextMode::Writer; use Moose; use Carp 'croak';
sub write { ## no critic (Subroutines::ProhibitBuiltinHomonyms) my ( $self, $image, $fh, $options ) = @_; $options ||= {}; $fh = _get_fh( $fh ); $self->_write( $image, $fh, $options ); $image->sauce->write( $fh ) if $image->has_sauce; } sub _get_fh { my ( $file ) = @_; my $fh = $file; if ( !ref $fh ) { undef $fh; open $fh, '>', $file ## no critic (InputOutput::RequireBriefOpen) or croak "Unable to open '$file': $!"; } binmode( $fh ); return $fh; } no Moose; __PACKAGE__->meta->make_immutable;
1;