1package Graphics::Primitive::Oriented;
2use Moose::Role;
3
4use Moose::Util::TypeConstraints;
5
6enum 'Graphics::Primitive::Orientations' => [qw(vertical horizontal)];
7
8has 'orientation' => (
9    is => 'rw',
10    isa => 'Graphics::Primitive::Orientations',
11);
12
13sub is_vertical {
14    my ($self) = @_;
15
16    return 0 unless $self->orientation;
17
18    return ($self->orientation eq 'vertical');
19}
20
21sub is_horizontal {
22    my ($self) = @_;
23
24    !$self->is_vertical;
25}
26
27no Moose;
281;
29__END__
30=head1 NAME
31
32Graphics::Primitive::Oriented - Role for components that care about
33orientation.
34
35=head1 SYNOPSIS
36
37Some components (or things that use components) require a bit more information
38than origin and width/height.  The orientation role allows a component to
39specify whether is vertically or horizontally oriented.
40
41    package My::Component;
42
43    extends 'Graphics::Primitive::Component';
44
45    with 'Graphics::Primitive::Oriented';
46
47    1;
48
49=head1 METHODS
50
51=over
52
53=item I<is_vertical>
54
55Returns true if the component is vertically oriented.
56
57=item I<is_horizontal>
58
59Returns true if the component is not vertically oriented.
60
61=item I<orientation>
62
63The way a component is oriented. Values allowed are 'horizontal' or
64'vertical'.
65
66
67=back
68
69=head1 AUTHOR
70
71Cory Watson, C<< <gphat@cpan.org> >>
72
73=head1 SEE ALSO
74
75perl(1)
76
77=head1 COPYRIGHT & LICENSE
78
79Copyright 2008-2010 by Cory G Watson.
80
81This program is free software; you can redistribute it and/or modify it
82under the same terms as Perl itself.