The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Class::Printable - A base class for Printable objects

SYNOPSIS

  package MyObject;
  our @ISA = ('Class::Printable');

DESCRIPTION

Sometimes it is nice to have your objects return something a bit more complex then MyObject=HASH(0x3bac438) when you print them. This module is a base class for adding that capability to your objects. This is a very simple class which when used as a base does not actually change the normal perl stringification behavior unless you override the classes toString method. Basically, it is there if you need it, and silent otherwise.

METHODS

toString

This implementation actually just calls stringValue so that your object will still retain the normal perl stringification behavior. However, if your subclass overrides this method, then the return value of it will be used whenever perl needs to stringify your object.

stringValue

This will return the unmolested stringification of your perl object.

OPERATORS

""

This operator, the stringification operator, is implemented with toString.

BUGS

None that I am aware of. Of course, if you find a bug, let me know, and I will be sure to fix it.

CODE COVERAGE

I use Devel::Cover to test the code coverage of my tests, below is the Devel::Cover report on this module test suite.

 ------------------------ ------ ------ ------ ------ ------ ------ ------
 File                       stmt branch   cond    sub    pod   time  total
 ------------------------ ------ ------ ------ ------ ------ ------ ------
 Class/Printable.pm        100.0    n/a    n/a  100.0  100.0  100.0  100.0
 ------------------------ ------ ------ ------ ------ ------ ------ ------
 Total                     100.0    n/a    n/a  100.0  100.0  100.0  100.0
 ------------------------ ------ ------ ------ ------ ------ ------ ------

SEE ALSO

This class is very simple, and is really nothing more than a wrapper around the stringification operator capabilities of overload.

AUTHOR

stevan little, <stevan@iinteractive.com>

COPYRIGHT AND LICENSE

Copyright 2004 by Infinity Interactive, Inc.

http://www.iinteractive.com

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.