]> git.vpit.fr Git - perl/modules/LaTeX-TikZ.git/blobdiff - lib/LaTeX/TikZ/Set/Path.pm
Make LT::Set::Path the base role, remove ::Op, and rename the old ::Path to ::Union
[perl/modules/LaTeX-TikZ.git] / lib / LaTeX / TikZ / Set / Path.pm
index 319298b3bd518dd87a2a213dff4910b3247f499c..f7a5fb21b684deb1afca328d216f41597d42db27 100644 (file)
@@ -5,59 +5,65 @@ use warnings;
 
 =head1 NAME
 
-LaTeX::TikZ::Set::Path - A set object representing a path.
+LaTeX::TikZ::Set::Path - A role for set objects that can be part of a path.
 
 =head1 VERSION
 
-Version 0.01
+Version 0.02
 
 =cut
 
-our $VERSION = '0.01';
+our $VERSION = '0.02';
 
-use LaTeX::TikZ::Tools;
+=head1 DESCRIPTION
 
-use Any::Moose;
+Paths are all the elements against which we can call the C<path> method.
 
-with qw(
- LaTeX::TikZ::Set::Op
- LaTeX::TikZ::Set::Mutable
-);
+=cut
 
-has '_ops' => (
- is       => 'ro',
- isa      => 'Maybe[ArrayRef[LaTeX::TikZ::Set::Op]]',
- init_arg => 'ops',
- default  => sub { [ ] },
-);
+use Any::Moose 'Role';
 
-sub ops { @{$_[0]->_ops} }
+=head1 RELATIONSHIPS
 
-my $ltso_tc = LaTeX::TikZ::Tools::type_constraint('LaTeX::TikZ::Set::Op');
+This role consumes the L<LaTeX::TikZ::Set> role, and as such implements the L</draw> method.
 
-sub add {
- my $set = shift;
+=cut
 
- $ltso_tc->check($_) for @_;
+with 'LaTeX::TikZ::Set';
 
- push @{$_[0]->_ops}, @_;
+=head1 METHODS
 
- $set;
-}
+This method is required by the interface :
+
+=over 4
+
+=item *
+
+C<path $formatter>
+
+Returns the TikZ code that builds a path out of the current set object as a string formatted by the L<LaTeX::TikZ::Formatter> object C<$formatter>.
 
-sub path {
+=back
+
+=cut
+
+requires qw<
+ path
+>;
+
+=head2 C<draw>
+
+=cut
+
+sub draw {
  my $set = shift;
 
join ' ', map $_->path(@_), $set->ops;
[ "\\draw " . $set->path(@_) . ' ;' ];
 }
 
-use LaTeX::TikZ::API path => sub {
- shift;
-
- __PACKAGE__->new(ops => \@_);
-};
+=head1 SEE ALSO
 
-__PACKAGE__->meta->make_immutable;
+L<LaTeX::TikZ>, L<LaTeX::TikZ::Set>.
 
 =head1 AUTHOR
 
@@ -84,4 +90,4 @@ This program is free software; you can redistribute it and/or modify it under th
 
 =cut
 
-1; # End of LaTeX::TikZ::Set::Path
+1; # End of LaTeX::TikZ::Set::Path;