File Coverage

blib/lib/Erlang/Parser/Node/Tuple.pm
Criterion Covered Total %
statement 14 14 100.0
branch 2 2 100.0
condition 2 2 100.0
subroutine 2 2 100.0
pod 1 1 100.0
total 21 21 100.0


line stmt bran cond sub pod time code
1             # Copyright 2011-2012 Yuki Izumi. ( anneli AT cpan DOT org )
2             # This is free software; you can redistribute it and/or modify it under the
3             # same terms as Perl itself.
4              
5             package Erlang::Parser::Node::Tuple;
6              
7 3     3   12 use Moose;
  3         3  
  3         15  
8             with 'Erlang::Parser::Node';
9              
10             has 'elems' => (is => 'rw', required => 1, isa => 'ArrayRef[Erlang::Parser::Node]');
11              
12             sub print {
13 4126     4126 1 4172 my ($self, $fh, $depth) = @_;
14 4126   100     6095 $depth ||= 0;
15              
16 4126         4215 print $fh '{';
17 4126         3030 my $first = 1;
18 4126         2952 foreach (@{$self->elems}) {
  4126         99612  
19 9582 100       11259 if ($first) { $first = 0 } else { print $fh ', ' }
  4122         3774  
  5460         5023  
20 9582         19063 $_->print($fh, $depth);
21             }
22              
23 4126         7356 print $fh '}';
24             }
25              
26             __PACKAGE__->meta->make_immutable;
27              
28             =head1 NAME
29              
30             Erlang::Parser::Node::Tuple - a tuple of items
31              
32             =head1 DESCRIPTION
33              
34             A set number of items; if you need something with variable length, use lists.
35              
36             =head2 Accessors
37              
38             =over 4
39              
40             =item C<elems>
41              
42             The L<Erlang::Parser::Node>s which make up the tuple's elements.
43              
44             =back
45              
46             =head2 Methods
47              
48             =over 4
49              
50             =item C<print>
51              
52             Pretty-prints the node to its filehandle argument.
53              
54             =back
55              
56             =head1 EXAMPLE
57              
58             {1, 2, 3}
59              
60             =cut
61              
62             1;
63              
64             # vim: set sw=4 ts=4: