TAIFEX/Contract.pm

filter: Statementstmt 66.6% 16 / 24 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 42.8% 3 / 7 Podpod 50.0% 2 / 4 totaltotal 60.0% 21 / 35 CC 1 SCAR 4.5
CC
1
Cov
67%
is_settlement_day
2.0
settlement_day
2.0
encode_local
2.0
CRAP 1.6
« default_cal.pl ↑ Summary TAIFEX.pm »
1 package Finance::TW::TAIFEX::Contract;
2 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use Any::Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 =head1 NAME
6  
7 Finance::TW::TAIFEX::Contract - Contract traded on TAIFEX
8  
9 =head1 METHODS
10  
11 =cut
12  
13 2 has year => (is => "ro", isa => "Int", required => 1);
14 2 has month => (is => "ro", isa => "Int", required => 1);
15 2 has product => (is => "ro", isa => "Finance::TW::TAIFEX::Product",
16 handles => [qw(name exchange find_settlement_day)],
17 );
18  
19 =head2 is_settlement_day DATE
20  
21 Check if DATE is a settlement day
22  
23 =cut
24  
25 0 ▶sub is_settlement_day {
Subroutine is_settlement_day: not called CC=1 SCAR=6.9
Pod documented
26 0 my ($self, $date) = @_;
27 0 return $date->ymd eq $self->settlement_day->ymd
28 }
29  
30 =head2 settlement_day
31  
32 Returns the settlement day of the contract.
33  
34 =cut
35  
36 0 ▶sub settlement_day {
Subroutine settlement_day: not called CC=1 SCAR=6.9
Pod documented
37 0 my $self = shift;
38  
39 0 $self->find_settlement_day(
40 DateTime->new( year => $self->year, month => $self->month, day => 1)
41 );
42 }
43  
44  
45 2 my $local_month_code = ['A'..'L'];
46 0 ▶sub encode_local {
Subroutine encode_local: not called CC=1 SCAR=6.9
Pod undocumented
47 0 my $self = shift;
48 0 return $local_month_code->[$self->month-1].substr($self->year, -1, 1);
49 }
50  
51 2 my $month_code = [qw(F G H J K M N Q U V X Z)];
52 0 ▶sub encode {
Subroutine encode: not called CC=1 SCAR=6.9
Pod undocumented
53 0 my $self = shift;
54 0 return $month_code->[$self->month-1].substr($self->year, -1, 1);
55 }
56  
57 2 __PACKAGE__->meta->make_immutable;
58 2 ▶no Any::Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
59 2 1;
60  
« default_cal.pl ↑ Summary TAIFEX.pm »