| 1 | package Bot::Cobalt::Plugin::Ohm; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 1 | $Bot::Cobalt::Plugin::Ohm::VERSION = '0.001002'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # A simple Ohm's law calculator borrowed from SYMKAT: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # https://gist.github.com/symkat/da287f0993e708b53701 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use strictures 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use Bot::Cobalt; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use Bot::Cobalt::Common; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | sub new { bless [], shift } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | sub Cobalt_register { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 0 | ▶ | my ($self, $core) = splice @_, 0, 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Cobalt_register: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 0 | my @events = map {; 'public_cmd_'.$_ } qw/ ohm watt amp volt /; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 0 | register $self, SERVER => [ @events ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 0 | $core->log->info("Loaded Ohm"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 0 | PLUGIN_EAT_NONE | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | sub Cobalt_unregister { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | ▶ | my ($self, $core) = splice @_, 0, 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Cobalt_unregister: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | $core->log->info("Unloaded Ohm"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | PLUGIN_EAT_NONE | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 1 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 1 | for (qw/watt amp volt/) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 3 | my $meth = 'Bot_public_cmd_'.$_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 3 | *{__PACKAGE__.'::'.$meth} = *Bot_public_cmd_ohm | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | sub Bot_public_cmd_ohm { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | ▶ | my ($self, $core) = splice @_, 0, 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Bot_public_cmd_ohm: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | my $msg = ${ $_[0] }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | my $context = $msg->context; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | my $src_nick = $msg->src_nick; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | my $str = join '', @{ $msg->message_array }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | my %parsed = $self->_parse_values($str); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | my $resp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | RESP: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | ▶ | unless (keys %parsed) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | $resp = "Parser failure, try input in the form of: <I>a <P>w <R>o <E>v"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | last RESP | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | $resp = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | ▶ | try { $self->_calc(%parsed) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | ▶ | catch { "Calc failure; $_" }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | unless (length $resp) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | $resp = "Calc failure; malformed input from parser"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | last RESP | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | } # RESP | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | broadcast message => $context, $msg->channel, "${src_nick}: $resp"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | PLUGIN_EAT_NONE | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | # These routines stolen directly from SYMKAT and then hacked to shreds: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | sub _parse_values { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 5 | ▶ | my ($self, $message) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_values: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 5 | my %values = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 5 | ▶ | if ( $message =~ /(\d+(?:\.\d+)?)o/i ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 4 | $values{o} = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 5 | ▶ | if ( $message =~ /(\d+(?:\.\d+)?)w/i ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 2 | $values{w} = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 5 | ▶ | if ( $message =~ /(\d+(?:\.\d+)?)a/i ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 1 | $values{a} = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 5 | ▶ | if ( $message =~ /(\d+(?:\.\d+)?)v/i ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 3 | $values{v} = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | %values | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 5 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | sub _calc { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 2 | ▶ | my ($self, %values) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_calc: called CC=33 SCAR=59.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | # A = V / O | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | # A = W / V | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | # A = sqrt(W / O) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 2 | ▶ | unless (defined $values{a}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | $values{a} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | $values{v} && $values{o} ? $values{v} / $values{o} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | : $values{w} && $values{v} ? $values{w} / $values{v} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | : $values{w} && $values{o} ? sqrt( $values{w} / $values{o} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 2 | ▶ | : undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition44%4/9
$values{"v"} and $values{"o"}
$values{"w"} and $values{"v"}
$values{"w"} and $values{"o"}
MC/DC50%1/2
$values{"v"} and $values{"o"}
$values{"v"}
$values{"o"}
MC/DC0%0/2
$values{"w"} and $values{"v"}
$values{"w"}
$values{"v"}
MC/DC0%0/2
$values{"w"} and $values{"o"}
$values{"w"}
$values{"o"}
Truth table66%2/3
A and B
A= $values{"v"}B= $values{"o"}
Truth table33%1/3
A and B
A= $values{"w"}B= $values{"v"}
Truth table33%1/3
A and B
A= $values{"w"}B= $values{"o"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | die "Not enough information to calculate amperage\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | unless defined $values{a} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 2 | ▶ | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | # W = ( V * V ) / O | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | # W = ( A * A ) * O | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | # W = V * R | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 1 | ▶ | unless (defined $values{w}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | $values{w} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | $values{v} && $values{o} ? ($values{v} ** 2) / $values{o} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | : $values{a} && $values{o} ? ($values{a} ** 2) * $values{o} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | : $values{v} && $values{a} ? $values{v} * $values{a} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | : undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 1 | ▶ | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition11%1/9
$values{"v"} and $values{"o"}
$values{"a"} and $values{"o"}
$values{"v"} and $values{"a"}
MC/DC0%0/2
$values{"v"} and $values{"o"}
$values{"v"}
$values{"o"}
MC/DC0%0/2
$values{"a"} and $values{"o"}
$values{"a"}
$values{"o"}
MC/DC0%0/2
$values{"v"} and $values{"a"}
$values{"v"}
$values{"a"}
Truth table33%1/3
A and B
A= $values{"v"}B= $values{"o"}
Truth table0%0/3
A and B
A= $values{"a"}B= $values{"o"}
Truth table0%0/3
A and B
A= $values{"v"}B= $values{"a"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | die "Not enough information to calculate wattage\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | unless defined $values{w} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 1 | ▶ | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | # O = V / A | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | # O = ( V * V ) * W | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | # O = W / ( A * A ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 1 | ▶ | unless (defined $values{o}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | $values{o} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | $values{v} && $values{a} ? $values{v} / $values{a} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | : $values{v} && $values{w} ? ($values{v} ** 2) * $values{w} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | ▶ | : $values{w} && $values{a} ? $values{w} / ($values{a} ** 2) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition0%0/9
$values{"v"} and $values{"a"}
$values{"v"} and $values{"w"}
$values{"w"} and $values{"a"}
MC/DC0%0/2
$values{"v"} and $values{"a"}
$values{"v"}
$values{"a"}
MC/DC0%0/2
$values{"v"} and $values{"w"}
$values{"v"}
$values{"w"}
MC/DC0%0/2
$values{"w"} and $values{"a"}
$values{"w"}
$values{"a"}
Truth table0%0/3
A and B
A= $values{"v"}B= $values{"a"}
Truth table0%0/3
A and B
A= $values{"v"}B= $values{"w"}
Truth table0%0/3
A and B
A= $values{"w"}B= $values{"a"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | : undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | die "Not enough information to calculate ohms\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | unless defined $values{o} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | ▶ | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | # V = sqrt( W * O ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | # V = W / A | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | # V = A * O | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 1 | ▶ | unless (defined $values{v}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | $values{v} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | $values{w} && $values{o} ? sqrt( $values{w} * $values{o} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | : $values{w} && $values{a} ? $values{w} / $values{a} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | : $values{a} && $values{o} ? $values{a} * $values{o} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | : undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition0%0/9
$values{"w"} and $values{"o"}
$values{"w"} and $values{"a"}
$values{"a"} and $values{"o"}
MC/DC0%0/2
$values{"w"} and $values{"o"}
$values{"w"}
$values{"o"}
MC/DC0%0/2
$values{"w"} and $values{"a"}
$values{"w"}
$values{"a"}
MC/DC0%0/2
$values{"a"} and $values{"o"}
$values{"a"}
$values{"o"}
Truth table0%0/3
A and B
A= $values{"w"}B= $values{"o"}
Truth table0%0/3
A and B
A= $values{"w"}B= $values{"a"}
Truth table0%0/3
A and B
A= $values{"a"}B= $values{"o"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | die "Not enough information to calculate voltage\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | unless defined $values{v} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | ▶ | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | sprintf | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | "%.2fw/%.2fv @ %.2famps against %.2fohm" => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 1 | map {; $values{$_} } qw/ w v a o / | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | Bot::Cobalt::Plugin::Ohm - Simple Ohm's law calculator for Bot::Cobalt | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | # What's my voltage and amperage firing my 0.87 Ohm coil at 25W? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | !ohm 0.87o 25w | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | A simple Ohm's law calculator; given a string specifying parameters in the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | form of C<< <N>a <N>o <N>w <N>v >>, attempts to fill in the blanks. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | Kaitlyn Parkhurst (CPAN: C<SYMKAT>) wrote the calculator as an irssi script. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | Adapted (with permission) to L<Bot::Cobalt> by Jon Portnoy <avenj@cobaltirc.org> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||