File Coverage

blib/lib/Biblio/ILL/ISO/ILLString.pm
Criterion Covered Total %
statement 17 36 47.2
branch 1 8 12.5
condition 1 6 16.6
subroutine 5 9 55.5
pod 0 6 0.0
total 24 65 36.9


line stmt bran cond sub pod time code
1             package Biblio::ILL::ISO::ILLString;
2              
3 4     4   23 use Biblio::ILL::ISO::ILLASNtype;
  4         8  
  4         107  
4 4     4   19 use Carp;
  4         9  
  4         374  
5              
6             our $VERSION = '0.01';
7             #---------------------------------------------------------------------------
8             # Mods
9             # 0.01 - 2003.07.15 - original version
10             #---------------------------------------------------------------------------
11              
12 4     4   1983 BEGIN{@ISA = qw ( Biblio::ILL::ISO::ILLASNtype );} # inherit from ILLASNtype
13              
14             # From the ASN
15             #
16             #ILL-String ::= CHOICE {
17             # generalstring GeneralString,
18             # -- may contain any ISO registered G (graphic) and C
19             # -- (control) character set
20             # edifactstring EDIFACTString
21             # }
22             # -- may not include leading or trailing spaces
23             # -- may not consist only of space (" ") or non-printing
24             # -- characters
25              
26              
27             #---------------------------------------------------------------
28             #
29             #---------------------------------------------------------------
30             sub new {
31 269     269 0 486 my $class = shift;
32 269         367 my $self = {};
33              
34 269 50       536 if (@_) {
35 269         570 $self->{"generalstring"} = shift;
36             }
37 269   33     1082 bless($self, ref($class) || $class);
38 269         873 return ($self);
39             }
40              
41             #---------------------------------------------------------------
42             #
43             #---------------------------------------------------------------
44             sub set {
45 111     111 0 135 my $self = shift;
46 111         131 my ($s) = @_;
47              
48 111         218 $self->{generalstring} = $s;
49 111         265 return;
50             }
51              
52              
53             #---------------------------------------------------------------
54             #
55             #---------------------------------------------------------------
56             sub set_general {
57 0     0 0   my $self = shift;
58 0           my ($s) = @_;
59              
60 0           $self->{generalstring} = $s;
61 0           return;
62             }
63              
64              
65             #---------------------------------------------------------------
66             #
67             #---------------------------------------------------------------
68             sub set_edifact {
69 0     0 0   my $self = shift;
70 0           my ($s) = @_;
71              
72 0           $self->{EDIFACTstring} = $s;
73 0           return;
74             }
75              
76              
77             #---------------------------------------------------------------
78             #
79             #---------------------------------------------------------------
80             sub as_string {
81 0     0 0   my $self = shift;
82              
83 0 0         return $self->{generalstring} if ($self->{generalstring});
84 0 0         return $self->{EDIFACTstring} if ($self->{EDIFACTstring});
85 0           return "";
86             }
87              
88             #---------------------------------------------------------------
89             #
90             #---------------------------------------------------------------
91             sub from_asn {
92 0     0 0   my $self = shift;
93 0           my $href = shift;
94              
95 0           foreach my $k (keys %$href) {
96             #print ref($self) . "...$k\n";
97              
98 0 0 0       if (($k =~ /^generalstring$/)
99             || ($k =~ /^edifactstring$/)
100             ) {
101             #print " $href->{$k}\n";
102 0           $self->{$k} = $href->{$k};
103              
104             } else {
105 0           croak "invalid " . ref($self) . " element: [$k]";
106             }
107              
108             }
109 0           return $self;
110             }
111              
112             1;