X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=lib%2FLaTeX%2FTikZ%2FSet%2FUnion.pm;fp=lib%2FLaTeX%2FTikZ%2FSet%2FUnion.pm;h=2648d3d77223810556025bdb637b234fca8ff056;hb=b8f42942311854cb0ef8a3e34c0145846639cd2e;hp=0000000000000000000000000000000000000000;hpb=65b895926935d98e3bd34b82a6e8b4e4e6b2f09c;p=perl%2Fmodules%2FLaTeX-TikZ.git diff --git a/lib/LaTeX/TikZ/Set/Union.pm b/lib/LaTeX/TikZ/Set/Union.pm new file mode 100644 index 0000000..2648d3d --- /dev/null +++ b/lib/LaTeX/TikZ/Set/Union.pm @@ -0,0 +1,127 @@ +package LaTeX::TikZ::Set::Union; + +use strict; +use warnings; + +=head1 NAME + +LaTeX::TikZ::Set::Union - A set object representing a path formed by the reunion of several subpaths. + +=head1 VERSION + +Version 0.02 + +=cut + +our $VERSION = '0.02'; + +use LaTeX::TikZ::Interface; +use LaTeX::TikZ::Functor; + +use LaTeX::TikZ::Tools; + +use Any::Moose; + +=head1 RELATIONSHIPS + +This class consumes the L and L roles, and as such implements the L and L methods. + +=cut + +with qw< + LaTeX::TikZ::Set::Path + LaTeX::TikZ::Set::Mutable +>; + +=head1 ATTRIBUTES + +=head2 C + +The L objects that form the path. + +=cut + +has '_kids' => ( + is => 'ro', + isa => 'Maybe[ArrayRef[LaTeX::TikZ::Set::Path]]', + init_arg => 'kids', + default => sub { [ ] }, +); + +sub kids { @{$_[0]->_kids} } + +=head1 METHODS + +=head2 C + +=cut + +my $ltsp_tc = LaTeX::TikZ::Tools::type_constraint('LaTeX::TikZ::Set::Path'); + +sub add { + my $set = shift; + + $ltsp_tc->assert_valid($_) for @_; + + push @{$set->_kids}, @_; + + $set; +} + +=head2 C + +=cut + +sub path { + my $set = shift; + + join ' ', map $_->path(@_), $set->kids; +} + +LaTeX::TikZ::Interface->register( + union => sub { + shift; + + __PACKAGE__->new(kids => \@_); + }, +); + +LaTeX::TikZ::Functor->default_rule( + (__PACKAGE__) => sub { + my ($functor, $set, @args) = @_; + $set->new(kids => [ map $_->$functor(@args), $set->kids ]) + } +); + +__PACKAGE__->meta->make_immutable; + +=head1 SEE ALSO + +L, L, L. + +=head1 AUTHOR + +Vincent Pit, C<< >>, L. + +You can contact me by mail or on C (vincent). + +=head1 BUGS + +Please report any bugs or feature requests to C, or through the web interface at L. +I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. + +=head1 SUPPORT + +You can find documentation for this module with the perldoc command. + + perldoc LaTeX::TikZ + +=head1 COPYRIGHT & LICENSE + +Copyright 2010 Vincent Pit, all rights reserved. + +This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. + +=cut + +1; # End of LaTeX::TikZ::Set::Union