File Coverage

blib/lib/AnyEvent/WebSocket/Message.pm
Criterion Covered Total %
statement 18 18 100.0
branch n/a
condition n/a
subroutine 10 10 100.0
pod 6 6 100.0
total 34 34 100.0


line stmt bran cond sub pod time code
1             package AnyEvent::WebSocket::Message;
2              
3 15     15   178957 use strict;
  15         28  
  15         379  
4 15     15   67 use warnings;
  15         28  
  15         288  
5 15     15   480 use Moo;
  15         11301  
  15         113  
6 15     15   5180 use Encode ();
  15         36  
  15         2740  
7              
8             # ABSTRACT: WebSocket message for AnyEvent
9             our $VERSION = '0.53'; # VERSION
10              
11              
12             has body => ( is => 'ro', required => 1 );
13             has opcode => ( is => 'ro', default => 1 );
14              
15              
16             sub decoded_body
17             {
18 20     20 1 7019 Encode::decode("UTF-8", shift->body)
19             }
20              
21              
22 115     115 1 23656 sub is_text { $_[0]->opcode == 1 }
23 42     42 1 4526 sub is_binary { $_[0]->opcode == 2 }
24 31     31 1 8582 sub is_close { $_[0]->opcode == 8 }
25 6     6 1 973 sub is_ping { $_[0]->opcode == 9 }
26 5     5 1 910 sub is_pong { $_[0]->opcode == 10 }
27              
28             1;
29              
30             __END__