
package Text::Wigwam::Stash::Base::Magic::String;

use strict;
use warnings;
no warnings 'uninitialized';

our $VERSION = '0.01';

use base 'Text::Wigwam::Stash::Base::Magic';
#use Scalar::Util qw( refaddr );

sub Ucfirst  { ucfirst $_[1] }
sub Lc       { lc $_[1] }
sub Uc       { uc $_[1] }
sub Length   { length $_[1] }
sub Inc      { return ( ++${$_[3]}, $_[3] ) }
sub Dec      { return ( --${$_[3]}, $_[3] ) }
sub Ord      { ord $_[1] }
sub Dollars  {
    local( $_ ) = sprintf "%.2f", $_[1];
    1 while s/(\d)(\d\d\d)(?!\d)/$1,$2/;
    return '$'.$_;
}
sub Defined  { defined ${$_[3]} }
sub Reference { $_[3] || \$_[1] }

sub DEFAULT  { $_[1], $_[3] }
# Size returns the size the array would be if this string were cast.
sub Size { return defined $_[1] && length $_[1] ? 1 : 0 }

1;
