Acme-Cow

 view release on metacpan or  search on metacpan

Cow/TextBalloon.pm  view on Meta::CPAN


  use Acme::Cow::TextBalloon;

  $x = new Acme::Cow::TextBalloon;
  $x->add("bunch of text");
  $x->wrapcolumn(29);

  $y = new Acme::Cow::TextBalloon;
  $y->adjust(0);
  $y->add("more text");

=head1 DESCRIPTION

C<Acme::Cow::TextBalloon> Creates and manipulates balloons of text,
optionally printing them.  One may notice that the methods in this
module are named very similarly to those in C<Acme::Cow>; that's
because most of them have to do with the balloon rather than the
cow.

=cut

use Text::Tabs;
use Text::Wrap;


sub new 
{
    my $proto = shift;
    my $class = ref $proto || $proto;
    my $self = {
	fill => 1,
	mode => 'say',
	over => 0,
	text => [ ],
	wrap => 40,
    };
    return bless $self, $class;
}

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

sub mode
{
    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";
}

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

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

sub as_list
{
    my $self = shift;
    return $self->_construct();
}

sub as_string 
{
    my $self = shift;
    return join('', $self->_construct());
}

sub add
{
    my $self = shift;
    push @{$self->{'text'}}, @_;
    return $self->{'text'};
}

sub text
{
    my $self = shift;
    if (@_) {
	my @l = @_;
	$self->{'text'} = \@l;
    }
    return $self->{'text'};
}

sub _maxlength 
{



( run in 2.631 seconds using v1.01-cache-2.11-cpan-14f38c9f855 )