]> git.vpit.fr Git - perl/modules/LaTeX-TikZ.git/blob - lib/LaTeX/TikZ/Set/Path.pm
18b9020d120da1ef7b26eedcb3379d8e5eb94632
[perl/modules/LaTeX-TikZ.git] / lib / LaTeX / TikZ / Set / Path.pm
1 package LaTeX::TikZ::Set::Path;
2
3 use strict;
4 use warnings;
5
6 =head1 NAME
7
8 LaTeX::TikZ::Set::Path - A set object representing a path.
9
10 =head1 VERSION
11
12 Version 0.01
13
14 =cut
15
16 our $VERSION = '0.01';
17
18 use Any::Moose;
19 use Any::Moose 'Util::TypeConstraints'
20                => [ qw/subtype as where find_type_constraint/ ];
21
22 with qw(
23  LaTeX::TikZ::Set::Op
24  LaTeX::TikZ::Set::Mutable
25 );
26
27 subtype 'LaTeX::TikZ::Set::Path::Elements'
28      => as 'Object'
29      => where { $_->does('LaTeX::TikZ::Set::Op') };
30
31 has '_ops' => (
32  is       => 'ro',
33  isa      => 'Maybe[ArrayRef[LaTeX::TikZ::Set::Path::Elements]]',
34  init_arg => 'ops',
35  default  => sub { [ ] },
36 );
37
38 sub ops { @{$_[0]->_ops} }
39
40 my $ltspe_tc = find_type_constraint('LaTeX::TikZ::Set::Path::Elements');
41
42 sub add {
43  my $set = shift;
44
45  $ltspe_tc->assert_valid($_) for @_;
46
47  push @{$set->_ops}, @_;
48
49  $set;
50 }
51
52 sub path {
53  my $set = shift;
54
55  join ' ', map $_->path(@_), $set->ops;
56 }
57
58 use LaTeX::TikZ::Interface path => sub {
59  shift;
60
61  __PACKAGE__->new(ops => \@_);
62 };
63
64 __PACKAGE__->meta->make_immutable;
65
66 =head1 AUTHOR
67
68 Vincent Pit, C<< <perl at profvince.com> >>, L<http://www.profvince.com>.
69
70 You can contact me by mail or on C<irc.perl.org> (vincent).
71
72 =head1 BUGS
73
74 Please report any bugs or feature requests to C<bug-latex-tikz at rt.cpan.org>, or through the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=LaTeX-TikZ>.
75 I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
76
77 =head1 SUPPORT
78
79 You can find documentation for this module with the perldoc command.
80
81     perldoc LaTeX::TikZ
82
83 =head1 COPYRIGHT & LICENSE
84
85 Copyright 2010 Vincent Pit, all rights reserved.
86
87 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
88
89 =cut
90
91 1; # End of LaTeX::TikZ::Set::Path