]> git.vpit.fr Git - perl/modules/LaTeX-TikZ.git/blob - lib/LaTeX/TikZ/Set/Line.pm
First cut at the documentation
[perl/modules/LaTeX-TikZ.git] / lib / LaTeX / TikZ / Set / Line.pm
1 package LaTeX::TikZ::Set::Line;
2
3 use strict;
4 use warnings;
5
6 =head1 NAME
7
8 LaTeX::TikZ::Set::Line - A set object representing a line.
9
10 =head1 VERSION
11
12 Version 0.01
13
14 =cut
15
16 our $VERSION = '0.01';
17
18 use LaTeX::TikZ::Set::Point;
19
20 use LaTeX::TikZ::Interface;
21 use LaTeX::TikZ::Functor;
22
23 use Any::Moose;
24
25 =head1 RELATIONSHIPS
26
27 This class consumes the L<LaTeX::TikZ::Set::Op> role, and as such implements the L</path> method.
28
29 =cut
30
31 with 'LaTeX::TikZ::Set::Op';
32
33 =head1 ATTRIBUTES
34
35 =head2 C<from>
36
37 The first endpoint of the line, as a L<LaTeX::TikZ::Set::Point> object.
38
39 =cut
40
41 has 'from' => (
42  is       => 'ro',
43  isa      => 'LaTeX::TikZ::Set::Point',
44  required => 1,
45  coerce   => 1,
46 );
47
48 =head2 C<to>
49
50 The second endpoint of the line, also as a L<LaTeX::TikZ::Set::Point> object.
51
52 =cut
53
54 has 'to' => (
55  is       => 'ro',
56  isa      => 'LaTeX::TikZ::Set::Point',
57  required => 1,
58  coerce   => 1,
59 );
60
61 =head1 METHODS
62
63 =head2 C<path>
64
65 =cut
66
67 sub path {
68  my $set = shift;
69
70  $set->from->path(@_) . ' -- ' . $set->to->path(@_);
71 }
72
73 LaTeX::TikZ::Interface->register(
74  line => sub {
75   shift;
76
77   __PACKAGE__->new(from => $_[0], to => $_[1]);
78  },
79 );
80
81 LaTeX::TikZ::Functor->default_rule(
82  (__PACKAGE__) => sub {
83   my ($functor, $set, @args) = @_;
84   $set->new(map { $_ => $set->$_->$functor(@args) } qw/from to/)
85  }
86 );
87
88 __PACKAGE__->meta->make_immutable;
89
90 =head1 AUTHOR
91
92 Vincent Pit, C<< <perl at profvince.com> >>, L<http://www.profvince.com>.
93
94 You can contact me by mail or on C<irc.perl.org> (vincent).
95
96 =head1 BUGS
97
98 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>.
99 I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
100
101 =head1 SUPPORT
102
103 You can find documentation for this module with the perldoc command.
104
105     perldoc LaTeX::TikZ
106
107 =head1 COPYRIGHT & LICENSE
108
109 Copyright 2010 Vincent Pit, all rights reserved.
110
111 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
112
113 =cut
114
115 1; # End of LaTeX::TikZ::Set::Line