Geometry::Primitive::Dimension - A width and height


Geometry-Primitive documentation Contained in the Geometry-Primitive distribution.

Index


Code Index:

NAME

Top

Geometry::Primitive::Dimension - A width and height

DESCRIPTION

Top

Geometry::Primitive::Dimension encapsulates a height and width.

SYNOPSIS

Top

  use Geometry::Primitive::Dimension;

  my $point = Geometry::Primitive::Dimeions->new(width => 100, height => 100);

ATTRIBUTES

Top

height

Set/Get the height value.

width

Set/Get the width value.

METHODS

Top

new

Creates a new Geometry::Primitive::Point.

equal_to

Compares this dimesion to another.

to_string

Return this dimesion as a string $widthx$height

AUTHOR

Top

Cory Watson <gphat@cpan.org>

COPYRIGHT & LICENSE

Top


Geometry-Primitive documentation Contained in the Geometry-Primitive distribution.

package Geometry::Primitive::Dimension;
use Moose;
use Moose::Util::TypeConstraints;
use MooseX::Storage;

with qw(Geometry::Primitive::Equal MooseX::Clone MooseX::Storage::Deferred);

use overload ('""' => 'to_string');

has 'height' => (
    is => 'rw',
    isa => 'Num',
    default => 0,
);
has 'width' => (
    is => 'rw',
    isa => 'Num',
    default => 0
);

coerce 'Geometry::Primitive::Dimension'
    => from 'ArrayRef'
        => via { Geometry::Primitive::Dimension->new(width => $_->[0], height => $_->[1]) };

sub equal_to {
    my ($self, $other) = @_;

    return (($self->width == $other->width) && $self->height == $other->height);
}

sub to_string {
    my ($self) = @_;

    return $self->width.'x'.$self->height;
}

__PACKAGE__->meta->make_immutable;

no Moose;
1;