File Coverage

blib/lib/Erlang/Parser/Node/RecordNew.pm
Criterion Covered Total %
statement 16 16 100.0
branch 2 2 100.0
condition 2 2 100.0
subroutine 2 2 100.0
pod 1 1 100.0
total 23 23 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::RecordNew;
6              
7 3     3   12 use Moose;
  3         3  
  3         14  
8             with 'Erlang::Parser::Node';
9              
10             has 'record' => (is => 'rw', required => 1, isa => 'Erlang::Parser::Node::Atom');
11             has 'exprs' => (is => 'rw', required => 1, isa => 'ArrayRef[Erlang::Parser::Node]');
12              
13             sub print {
14 448     448 1 556 my ($self, $fh, $depth) = @_;
15 448   100     1009 $depth ||= 0;
16              
17 448         526 print $fh '#';
18 448         11641 $self->record->print($fh, $depth);
19 448         600 print $fh '{';
20              
21 448         463 my $first = 1;
22 448         401 foreach (@{$self->exprs}) {
  448         11651  
23 596 100       979 if ($first) { $first = 0 } else { print $fh ', ' }
  416         394  
  180         220  
24 596         1501 $_->print($fh, $depth);
25             }
26              
27 448         1020 print $fh '}';
28             }
29              
30             __PACKAGE__->meta->make_immutable;
31              
32             =head1 NAME
33              
34             Erlang::Parser::Node::RecordNew - creation of a new record
35              
36             =head1 DESCRIPTION
37              
38             Creation of a record based on a record definition.
39              
40             =head2 Accessors
41              
42             =over 4
43              
44             =item C<record>
45              
46             The name of the record definition being used.
47              
48             =item C<exprs>
49              
50             A list of L<Erlang::Parser::Node>s which instantiate fields in the record.
51              
52             =back
53              
54             =head2 Methods
55              
56             =over 4
57              
58             =item C<print>
59              
60             Pretty-prints the node to its filehandle argument.
61              
62             =back
63              
64             =head1 EXAMPLE
65              
66             #state{S=4}
67              
68             =cut
69              
70             1;
71              
72             # vim: set sw=4 ts=4: