roles

 view release on metacpan or  search on metacpan

lib/roles.pm  view on Meta::CPAN

    }

    package US::Currency {
        use strict;
        use warnings;

        use roles 'Comparable', 'Printable';

        sub new {
            my ($class, %args) = @_;
            bless { amount => $args{amount} // 0 } => $class;
        }

        sub compare {
            my ($self, $other) = @_;
            $self->{amount} <=> $other->{amount};
        }

        sub to_string {
            my ($self) = @_;
            sprintf '$%0.2f USD' => $self->{amount};



( run in 0.435 second using v1.01-cache-2.11-cpan-65fba6d93b7 )