Acme-Cow
view release on metacpan or search on metacpan
=head1 NAME
Acme::Cow - Talking barnyard animals (or ASCII art in general)
=head1 SYNOPSIS
use Acme::Cow;
$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;
$self->{'mode'} = 'think';
if (@_) {
$self->text(@_);
}
}
=pod
=head2 SAY
Tell the cow to say its text instead of thinking it.
=over 4
=item Parameters
(optional) Text to say.
=item Returns
None.
=back
=cut
sub say
{
my $self = shift;
$self->{'mode'} = 'say';
if (@_) {
$self->text(@_);
}
}
=pod
=head2 text
Set (or retrieve) the text that the cow will say or think.
=over 4
=item Parameters
A list of lines of text (optionally terminated with newlines) to
be displayed inside the balloon.
=item Returns
Cow/TextBalloon.pm view on Meta::CPAN
my $self = shift;
return $self->{'mode'};
}
sub think
{
my $self = shift;
$self->{'mode'} = "think";
}
sub say
{
my $self = shift;
$self->{'mode'} = "say";
}
sub print
{
my $self = shift;
$self->{'mode'} = "think";
}
=====================
Acme::Cow version 0.1
=====================
Talking cows. ASCII artwork. A veritable foundation of the
Internet.
Now you can make the cows say whatever you want. Acme::Cow is the
module that does all the work behind the new version of cow{say,think}
(also included in this distribution). Now you can incorporate
loquactious cattle into any program you want, quickly and easily.
INSTALLATION
To install this module type the following:
perl Makefile.PL
make
my @text = &slurp_input();
if ($opts{'f'}) {
$cow = &variant_cow($opts{'f'});
} else {
$cow = new Acme::Cow();
}
&construct_face($cow);
if (index($0, "think") != -1) {
$cow->think(@text);
} else {
$cow->say(@text);
}
$cow->fill(not $opts{'n'});
$cow->wrap($opts{'W'});
$cow->print();
sub list_cowfiles {
my $basedir;
for my $d (split(/$pathsep/, $cowpath)) {
print "Cow files in $d:\n";
opendir(COWDIR, $d) || die "$0: Cannot open $d\n";
my @text = &slurp_input();
if ($opts{'f'}) {
$cow = &variant_cow($opts{'f'});
} else {
$cow = new Acme::Cow();
}
&construct_face($cow);
if (index($0, "think") != -1) {
$cow->think(@text);
} else {
$cow->say(@text);
}
$cow->fill(not $opts{'n'});
$cow->wrap($opts{'W'});
$cow->print();
sub list_cowfiles {
my $basedir;
for my $d (split(/$pathsep/, $cowpath)) {
print "Cow files in $d:\n";
opendir(COWDIR, $d) || die "$0: Cannot open $d\n";
t/balloon.t view on Meta::CPAN
$x->text(" Hi.");
$x->over(6);
compare_bubbles($x->as_string(), <<'EOB');
______
( Hi. )
------
EOB
$x->print();
$x->adjust(0);
$x->say();
$x->over(0);
$x->text(
"A limerick packs laughs anatomical\n",
"Into space that is quite economical.\n",
"\tBut the good ones I've seen\n",
"\tSo seldom are clean\n",
"And the clean ones so seldom are comical.\n"
);
compare_bubbles($x->as_string(), <<'EOB');
( run in 0.681 second using v1.01-cache-2.11-cpan-5511b514fd6 )