| 1 | # | ||||||||||||||||||||||||||||
| 2 | # This file is part of TBX-Min | ||||||||||||||||||||||||||||
| 3 | # | ||||||||||||||||||||||||||||
| 4 | # This software is copyright (c) 2016 by Alan Melby. | ||||||||||||||||||||||||||||
| 5 | # | ||||||||||||||||||||||||||||
| 6 | # This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||
| 7 | # the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||
| 8 | # | ||||||||||||||||||||||||||||
| 9 | package TBX::Min::LangSet; | ||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 1 | our $VERSION = '0.08'; # VERSION | |||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | # ABSTRACT: Store information from one TBX-Min C<langSet> element | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 1 | my %valid = map {$_ => 1} qw(code term_groups); | |||||||||||||||||||||||||||
| 18 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||
| 19 | 0 | my ($class, $args) = @_; | |||||||||||||||||||||||||||
| 20 | 0 | my $self; | |||||||||||||||||||||||||||
| 21 | 0 | ▶ | if((ref $args) eq 'HASH'){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 22 | # validate arguments | ||||||||||||||||||||||||||||
| 23 | 0 | ▶ | if(my @invalids = grep {!$valid{$_}} sort keys %$args){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 24 | 0 | croak 'Invalid attributes for class: ' . | |||||||||||||||||||||||||||
| 25 | join ' ', @invalids | ||||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||
| 27 | 0 | ▶ | if($args->{term_groups} && ref $args->{term_groups} ne 'ARRAY'){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$args->{"term_groups"} and ref $args->{"term_groups"} ne "ARRAY"
MC/DC0%0/2
$args->{"term_groups"} and ref $args->{"term_groups"} ne "ARRAY"
$args->{"term_groups"}
ref $args->{"term_groups"} ne "ARRAY"
Truth table0%0/3
A and B
A= $args->{"term_groups"}B= ref $args->{"term_groups"} ne "ARRAY"
| |||||||||||||||||||||||||||||
| 28 | 0 | croak q{Attribute 'term_groups' should be an array reference}; | |||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||
| 30 | 0 | $self = $args; | |||||||||||||||||||||||||||
| 31 | }else{ | ||||||||||||||||||||||||||||
| 32 | 0 | $self = {}; | |||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||
| 34 | 0 | ▶ | $self->{term_groups} ||= []; | ||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"term_groups"} ||= []
MC/DC0%0/1
$self->{"term_groups"} ||= []
$self->{"term_groups"}
Truth table0%0/2
A
A= $self->{"term_groups"}
| |||||||||||||||||||||||||||||
| 35 | 0 | return bless $self, $class; | |||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 0 | ▶ | sub code { | ||||||||||||||||||||||||||
|
Subroutine
code: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 39 | 0 | my ($self, $code) = @_; | |||||||||||||||||||||||||||
| 40 | 0 | ▶ | if($code) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 41 | 0 | return $self->{code} = $code; | |||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | 0 | return $self->{code}; | |||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 0 | ▶ | sub term_groups { ## no critic(RequireArgUnpacking) | ||||||||||||||||||||||||||
|
Subroutine
term_groups: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 47 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 48 | 0 | ▶ | if (@_ > 1){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 49 | 0 | croak 'extra argument found (term_groups is a getter only)'; | |||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | 0 | return $self->{term_groups}; | |||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 0 | ▶ | sub add_term_group { | ||||||||||||||||||||||||||
|
Subroutine
add_term_group: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 55 | 0 | my ($self, $term_grp) = @_; | |||||||||||||||||||||||||||
| 56 | 0 | ▶ | if( !$term_grp || !$term_grp->isa('TBX::Min::TIG') ){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$term_grp and $term_grp->isa("TBX::Min::TIG")
MC/DC0%0/2
$term_grp and $term_grp->isa("TBX::Min::TIG")
$term_grp
$term_grp->isa("TBX::Min::TIG")
Truth table0%0/3
A and B
A= $term_grpB= $term_grp->isa("TBX::Min::TIG")
| |||||||||||||||||||||||||||||
| 57 | 0 | croak 'argument to add_term_group should be a TBX::Min::TIG'; | |||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | 0 | push @{$self->{term_groups}}, $term_grp; | |||||||||||||||||||||||||||
| 60 | 0 | return; | |||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | 1 | 1; | |||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | __END__ | ||||||||||||||||||||||||||||