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   232682 use strict;
  15         54  
  15         453  
4 15     15   85 use warnings;
  15         59  
  15         383  
5 15     15   659 use Moo;
  15         11845  
  15         118  
6 15     15   5952 use Encode ();
  15         124  
  15         3315  
7              
8             # ABSTRACT: WebSocket message for AnyEvent
9             our $VERSION = '0.55'; # 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 7768 Encode::decode("UTF-8", shift->body)
19             }
20              
21              
22 115     115 1 9378 sub is_text { $_[0]->opcode == 1 }
23 42     42 1 19318 sub is_binary { $_[0]->opcode == 2 }
24 31     31 1 1357 sub is_close { $_[0]->opcode == 8 }
25 6     6 1 1174 sub is_ping { $_[0]->opcode == 9 }
26 5     5 1 11458 sub is_pong { $_[0]->opcode == 10 }
27              
28             1;
29              
30             __END__