File Coverage

blib/lib/Bio/Tools/EUtilities/Info/FieldInfo.pm
Criterion Covered Total %
statement 34 44 77.2
branch 8 12 66.6
condition 7 15 46.6
subroutine 15 16 93.7
pod 11 11 100.0
total 75 98 76.5


line stmt bran cond sub pod time code
1             package Bio::Tools::EUtilities::Info::FieldInfo;
2             $Bio::Tools::EUtilities::Info::FieldInfo::VERSION = '1.77';
3 1     1   7 use utf8;
  1         4  
  1         6  
4 1     1   31 use strict;
  1         2  
  1         18  
5 1     1   4 use warnings;
  1         2  
  1         36  
6 1     1   7 use base qw(Bio::Root::Root Bio::Tools::EUtilities::EUtilDataI);
  1         2  
  1         807  
7              
8             # ABSTRACT: Class for storing einfo field data.
9             # AUTHOR: Chris Fields
10             # OWNER: 2006-2013 Chris Fields
11             # LICENSE: Perl_5
12              
13              
14              
15             sub new {
16 41     41 1 453 my ($class, @args) = @_;
17 41         104 my $self = $class->SUPER::new(@args);
18 41         945 $self->eutil('einfo');
19 41         105 $self->datatype('fieldinfo');
20 41         97 return $self;
21             }
22              
23              
24 2     2 1 570 sub get_term_count { return shift->{'_termcount'} }
25              
26              
27 2     2 1 11 sub get_field_name { return shift->{'_fullname'} }
28              
29              
30             *get_full_name = \&get_field_name;
31              
32              
33 2     2 1 11 sub get_field_code { return shift->{'_name'} }
34              
35              
36 2     2 1 18 sub get_field_description { return shift->{'_description'} }
37              
38              
39             sub is_date {
40 2     2 1 7 my $self = shift;
41 2 50 33     22 ($self->{'_isdate'} && $self->{'_isdate'} eq 'Y') ? return 1 : return 0;
42             }
43              
44              
45             sub is_singletoken {
46 2     2 1 5 my $self = shift;
47 2 50 33     20 ($self->{'_singletoken'} && $self->{'_singletoken'} eq 'Y') ? return 1 : return 0;
48             }
49              
50              
51             sub is_hierarchy {
52 2     2 1 5 my $self = shift;
53 2 50 33     16 ($self->{'hierarchy'} && $self->{'hierarchy'} eq 'Y') ? return 1 : return 0;
54             }
55              
56              
57             sub is_hidden {
58 2     2 1 4 my $self = shift;
59 2 100 66     23 ($self->{'_ishidden'} && $self->{'_ishidden'} eq 'Y') ? return 1 : return 0;
60             }
61              
62              
63             sub is_numerical {
64 2     2 1 5 my $self = shift;
65 2 100 66     22 ($self->{'_isnumerical'} && $self->{'_isnumerical'} eq 'Y') ? return 1 : return 0;
66             }
67              
68             # private EUtilDataI method
69              
70             sub _add_data {
71 41     41   71 my ($self, $simple) = @_;
72 41 50       107 map { $self->{'_'.lc $_} = $simple->{$_} unless ref $simple->{$_}} keys %$simple;
  410         1537  
73             }
74              
75              
76             sub to_string {
77 0     0 1   my $self = shift;
78             # order method name
79 0           my %tags = (1 => ['get_field_code' => 'Field Code'],
80             2 => ['get_field_name' => 'Field Name'],
81             3 => ['get_field_description' => 'Description'],
82             4 => ['get_term_count' => 'Term Count']);
83 0           my $string;
84 0           for my $tag (sort {$a <=> $b} keys %tags) {
  0            
85 0           my ($m, $nm) = ($tags{$tag}->[0], $tags{$tag}->[1]);
86 0           $string .= sprintf("%-20s%s\n", $nm,
87             $self->_text_wrap('', ' 'x20 .':', ":".$self->$m));
88             }
89             $string .= sprintf("%-20s%s\n", "Attributes",
90 0           $self->_text_wrap('', ' 'x20 .':', ":".join(',', grep {$self->$_} qw(is_date
  0            
91             is_singletoken is_hierarchy is_hidden is_numerical))));
92 0           return $string;
93             }
94              
95             1;
96              
97             __END__