| 1 | package Finance::StockAccount::Stock; | ||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||
| 3 | 10 | our $VERSION = '0.01'; | |||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||
| 5 | 10 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 6 | 10 | ▶ | use warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||
| 8 | 276 | ▶ | sub new { | ||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 9 | 276 | my ($class, $init) = @_; | |||||||||||||||||||||||||||||||
| 10 | 276 | my $self = { | |||||||||||||||||||||||||||||||
| 11 | symbol => undef, | ||||||||||||||||||||||||||||||||
| 12 | exchange => undef, | ||||||||||||||||||||||||||||||||
| 13 | }; | ||||||||||||||||||||||||||||||||
| 14 | 276 | bless($self, $class); | |||||||||||||||||||||||||||||||
| 15 | 276 | ▶ | $init and $self->set($init); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 16 | 276 | return $self; | |||||||||||||||||||||||||||||||
| 17 | } | ||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||
| 19 | 1 | ▶ | sub set { | ||||||||||||||||||||||||||||||
|
Subroutine
set: called CC=3 SCAR=12.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 20 | 1 | my ($self, $init) = @_; | |||||||||||||||||||||||||||||||
| 21 | 1 | for my $key (keys %$init) { | |||||||||||||||||||||||||||||||
| 22 | 1 | ▶ | if (exists($self->{$key})) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 23 | 1 | $self->{$key} = $init->{$key}; | |||||||||||||||||||||||||||||||
| 24 | 1 | return 1; | |||||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||||||
| 26 | else { | ||||||||||||||||||||||||||||||||
| 27 | 0 | warn "Tried to set $key in Finance::StockAccount::Stock object, but that's not a known key.\n"; | |||||||||||||||||||||||||||||||
| 28 | 0 | return 0; | |||||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||
| 33 | 1634 | ▶ | sub symbol { | ||||||||||||||||||||||||||||||
|
Subroutine
symbol: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 34 | 1634 | my ($self, $symbol) = @_; | |||||||||||||||||||||||||||||||
| 35 | 1634 | ▶ | if ($symbol) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 36 | 275 | $self->{symbol} = $symbol; | |||||||||||||||||||||||||||||||
| 37 | 275 | return 1; | |||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||
| 39 | else { | ||||||||||||||||||||||||||||||||
| 40 | 1359 | return $self->{symbol}; | |||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||
| 44 | 534 | ▶ | sub exchange { | ||||||||||||||||||||||||||||||
|
Subroutine
exchange: called CC=2 SCAR=8.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 45 | 534 | my ($self, $exchange) = @_; | |||||||||||||||||||||||||||||||
| 46 | 534 | ▶ | if ($exchange) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 47 | 0 | $self->{exchange} = $exchange; | |||||||||||||||||||||||||||||||
| 48 | 0 | return 1; | |||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||
| 50 | else { | ||||||||||||||||||||||||||||||||
| 51 | 534 | return $self->{exchange}; | |||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||
| 55 | 266 | ▶ | sub same { | ||||||||||||||||||||||||||||||
|
Subroutine
same: called CC=6 SCAR=24.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 56 | 266 | my ($self, $stock) = @_; | |||||||||||||||||||||||||||||||
| 57 | 266 | my $symbol = $self->symbol(); | |||||||||||||||||||||||||||||||
| 58 | 266 | ▶ | if ($symbol and $symbol eq $stock->symbol()) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$symbol and $symbol eq $stock->symbol
MC/DC0%0/2
$symbol and $symbol eq $stock->symbol
$symbol
$symbol eq $stock->symbol
Truth table33%1/3
A and B
A= $symbolB= $symbol eq $stock->symbol
| |||||||||||||||||||||||||||||||||
| 59 | 266 | my $exchange = $self->exchange(); | |||||||||||||||||||||||||||||||
| 60 | 266 | ▶ | if ($exchange or $stock->exchange()) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$exchange or $stock->exchange
MC/DC0%0/2
$exchange or $stock->exchange
$exchange
$stock->exchange
Truth table33%1/3
A or B
A= $exchangeB= $stock->exchange
| |||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | if ($exchange eq $stock->exchange()) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 62 | 0 | return 1; | |||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||
| 64 | else { | ||||||||||||||||||||||||||||||||
| 65 | 0 | return 0; | |||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||
| 68 | 266 | return 1; | |||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||
| 70 | else { | ||||||||||||||||||||||||||||||||
| 71 | 0 | return 0; | |||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||
| 75 | 257 | ▶ | sub hashKey { | ||||||||||||||||||||||||||||||
|
Subroutine
hashKey: called CC=4 SCAR=17.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 76 | 257 | my $self = shift; | |||||||||||||||||||||||||||||||
| 77 | 257 | my $symbol = $self->{symbol}; | |||||||||||||||||||||||||||||||
| 78 | 257 | my $exchange = $self->{exchange}; | |||||||||||||||||||||||||||||||
| 79 | 257 | ▶ | if ($symbol and $exchange) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
$symbol and $exchange
MC/DC0%0/2
$symbol and $exchange
$symbol
$exchange
Truth table33%1/3
A and B
A= $symbolB= $exchange
| |||||||||||||||||||||||||||||||||
| 80 | 0 | return "$symbol:$exchange"; | |||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||
| 82 | elsif ($symbol) { | ||||||||||||||||||||||||||||||||
| 83 | 257 | return $symbol; | |||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||
| 85 | else { | ||||||||||||||||||||||||||||||||
| 86 | 0 | warn "Cannot generate hash key when stock symbol not set.\n"; | |||||||||||||||||||||||||||||||
| 87 | 0 | return undef; | |||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||
| 93 | 10 | 1; | |||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||
| 95 | __END__ | ||||||||||||||||||||||||||||||||