Acme-Cow

 view release on metacpan or  search on metacpan

Cow.pm  view on Meta::CPAN


  $cow = new Acme::Cow;
  $cow->say("Moo!");
  $cow->print();

  $sheep = new Acme::Cow::Sheep;	# Derived from Acme::Cow
  $sheep->wrap(20);
  $sheep->think();
  $sheep->text("Yeah, but you're taking the universe out of context.");
  $sheep->print(\*STDERR);

  $duck = new Acme::Cow(File => "duck.cow");
  $duck->fill(0);
  $duck->say(`figlet quack`);
  $duck->print($socket);


=head1 DESCRIPTION

Acme::Cow is the logical evolution of the old cowsay program.  Cows
are derived from a base class (Acme::Cow) or from external files.

Cows can be made to say or think many things, optionally filling
and justifying their text out to a given margin,

Cows are nothing without the ability to print them, or sling them
as strings, or what not.

=cut

use Acme::Cow::TextBalloon;
use IO::File;
use Text::Template;

$Acme::Cow::default_cow = <<'EOC';
{$balloon}
        {$tl}   ^__^
         {$tl}  ({$el}{$er})\_______
            (__)\       )\/\
             {$U} ||----w |
                ||     ||
EOC

=pod

=head1 METHODS

=head2 new

=over 4

=item Parameters

A list of key-value pairs.  If you plan to use an external file as
the template, you probably want to say:

	$x = new Acme::Cow(File => 'file.cow');

=item Returns

A blessed reference to an C<Acme::Cow>.

=back

=cut

sub new 
{
    my $proto = shift;
    my $class = ref $proto || $proto;
    my %args = @_;
    my $self = {
	wrap => 40,
	mode => 'say',
	fill => 1,
	over => 0,
	text => undef,
	el => 'o',
	er => 'o',
	U => '  ',
	%args,
    };
    bless $self, $class;
}

=pod

=head2 over

Specify (or retrieve) how far to the right (in spaces) the text
balloon should be shoved.

=over 4

=item Parameters

(optional) A number.

=item Returns

The new value, if set; the existing value if not.

=back

=cut

sub over
{
    my $self = shift;
    if (@_) {
	$self->{'over'} = $_[0];
    }
    return $self->{'over'};
}

=pod

=head2 wrap

Specify (or retrieve) the column at which text inside the balloon
should be wrapped.  This number is relative to the balloon, not
absolute screen position.

=over 4

=item Parameters

(optional) A number.

=item Returns

The new value, if set; the existing value if not.

=item Notes

The number set here has no effect if you decline filling/adjusting
of the balloon text.

=back

=cut

sub wrap 



( run in 3.008 seconds using v1.01-cache-2.11-cpan-99c4e6809bf )