IRC/Convert.pm

filter: Statementstmt 100% 19 / 19 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 1 totaltotal 92.5% 25 / 27 CC 2 SCAR 2.9
CC
2
Cov
95%
__ANON__
2.0
init
1.0
BEGIN
1.0
CRAP 1.3
« IRC/Seen.pm ↑ Summary
1 package Bot::IRC::Convert;
2 # ABSTRACT: Bot::IRC convert units of amounts
3  
4 2 ▶use 5.016;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use exact -noutf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 ▶use Math::Units 'convert';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 2 our $VERSION = '1.49'; # VERSION
10  
11 1 ▶sub init {
Subroutine init: called CC=1 SCAR=0.0
Pod undocumented
12 1 my ($bot) = @_;
13  
14 $bot->hook(
15 {
16 command => 'PRIVMSG',
17 text => qr/^(?<amount>[\d,\.]+)\s+(?<in_unit>\S+)\s+(?:in|as|to|into)\s+(?<out_unit>\S+)/,
18 },
19 1 ▶ sub {
Subroutine __ANON__: called CC=2 SCAR=7.0
20 1 my ( $bot, $in, $m ) = @_;
21  
22 1 ( my $amount = $m->{amount} ) =~ s/,//g;
23 1 my $value;
24 1 eval { $value = convert( $amount, $m->{in_unit}, $m->{out_unit} ) };
25  
26 1 ▶ $bot->reply("$m->{amount} $m->{in_unit} is $value $m->{out_unit}") if ($value);
Branch: 1 branch
BranchTrueFalseTotal
if $value 1 0 1
27 },
28 1 );
29  
30 1 $bot->helps( convert => 'Convert units of value. Usage: <amount> <input unit> as <output unit>.' );
31 }
32  
33 2 1;
34  
35 __END__
« IRC/Seen.pm ↑ Summary