File Coverage

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


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::Directive;
6              
7 3     3   1628 use Moose;
  3         918057  
  3         16  
8             with 'Erlang::Parser::Node';
9              
10             has 'directive' => (is => 'rw', required => 1, isa => 'Str');
11             has 'args' => (is => 'rw', required => 1, isa => 'ArrayRef[Erlang::Parser::Node]');
12              
13             sub print {
14 474     474 1 5067 my ($self, $fh, $depth) = @_;
15 474   50     1345 $depth ||= 0;
16              
17 474         12331 print $fh "-", $self->directive, "(";
18 474         505 my $first = 1;
19              
20 474         459 foreach (@{$self->args}) {
  474         11514  
21 608 100       880 if ($first) { $first = 0 } else { print $fh ', ' }
  474         506  
  134         150  
22 608         1684 $_->print($fh, $depth);
23             }
24 474         809 print $fh ").\n";
25             }
26              
27             __PACKAGE__->meta->make_immutable;
28              
29             =head1 NAME
30              
31             Erlang::Parser::Node::Directive - a compiler directive
32              
33             =head1 DESCRIPTION
34              
35             Any pragma to the compiler.
36              
37             =head2 Accessors
38              
39             =over 4
40              
41             =item C<directive>
42              
43             The name of the pragma.
44              
45             =item C<args>
46              
47             A list of L<Erlang::Parser::Node>s which make up the arguments of the
48             directive, if any.
49              
50             =back
51              
52             =head2 Methods
53              
54             =over 4
55              
56             =item C<print>
57              
58             Pretty-prints the node to its filehandle argument.
59              
60             =back
61              
62             =head1 EXAMPLE
63              
64             -export([a/0]).
65              
66             =cut
67              
68             1;
69              
70             # vim: set sw=4 ts=4: