File Coverage

blib/lib/Erlang/Parser/Node/ReceiveAfter.pm
Criterion Covered Total %
statement 17 17 100.0
branch 2 2 100.0
condition 1 2 50.0
subroutine 2 2 100.0
pod 1 1 100.0
total 23 24 95.8


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::ReceiveAfter;
6              
7 3     3   13 use Moose;
  3         4  
  3         16  
8             with 'Erlang::Parser::Node';
9              
10             has 'time' => (is => 'rw', required => 1, isa => 'Erlang::Parser::Node');
11             has 'stmts' => (is => 'rw', required => 0, isa => 'ArrayRef[Erlang::Parser::Node]');
12              
13             sub print {
14 6     6 1 9 my ($self, $fh, $depth) = @_;
15 6   50     13 $depth ||= 0;
16              
17 6         11 print $fh 'after ';
18 6         156 $self->time->print($fh, $depth);
19              
20 6         10 $depth++;
21 6         13 print $fh " ->\n", "\t" x $depth;
22              
23 6         11 my $first = 1;
24 6         6 foreach (@{$self->stmts}) {
  6         157  
25 10 100       20 if ($first) { $first = 0 } else { print $fh ",\n", "\t" x $depth }
  6         8  
  4         9  
26 10         24 $_->print($fh, $depth);
27             }
28              
29 6         16 $depth--;
30             }
31              
32             __PACKAGE__->meta->make_immutable;
33              
34             =head1 NAME
35              
36             Erlang::Parser::Node::ReceiveAfter - the after clause for a receive statement
37              
38             =head1 DESCRIPTION
39              
40             Specifies the length of time after which the clause should activate, and the
41             statement block to execute in that case.
42              
43             =head2 Accessors
44              
45             =over 4
46              
47             =item C<time>
48              
49             A L<Erlang::Parser::Node> that yields the number of milliseconds, or the atom
50             infinity.
51              
52             =item C<stmts>
53              
54             A list of L<Erlang::Parser::Node>s to run if the timeout is activated.
55              
56             =back
57              
58             =head2 Methods
59              
60             =over 4
61              
62             =item C<print>
63              
64             Pretty-prints the node to its filehandle argument.
65              
66             =back
67              
68             =head1 EXAMPLE
69              
70             after X ->
71             Y
72              
73             =cut
74              
75             1;
76              
77             # vim: set sw=4 ts=4: