lib/LaTeXML/Pre/BibTeX/Entry.pm untested

filter: Statementstmt 0.0% 0 / 44 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 12 Podpod 0.0% 0 / 9 totaltotal 0.0% 0 / 65 CC 1 SCAR 6.9
CC
1
Cov
0%
new
2.0
getType
2.0
getKey
2.0
CRAP 2.0
1 # /=====================================================================\ #
2 # | LaTeXML::Pre::BibTeX::Entry | #
3 # | Implements BibTeX for LaTeXML | #
4 # |=====================================================================| #
5 # | Part of LaTeXML: | #
6 # | Public domain software, produced as part of work done by the | #
7 # | United States Government & not subject to copyright in the US. | #
8 # |---------------------------------------------------------------------| #
9 # | Bruce Miller <bruce.miller@nist.gov> #_# | #
10 # | http://dlmf.nist.gov/LaTeXML/ (o o) | #
11 # \=========================================================ooo==U==ooo=/ #
12 package LaTeXML::Pre::BibTeX::Entry;
13 use strict;
14 use warnings;
15 use List::Util qw(min max);
16  
17 sub new {
18 my ($class, $type, $key, $fields, $rawfields) = @_;
19 my $self = { type => $type, key => $key,
20 fieldlist => $fields, rawfieldlist => $rawfields,
21 fieldmap => { map { ($$_[0] => $$_[1]) } @$fields },
22 rawfieldmap => { map { ($$_[0] => $$_[1]) } @$rawfields } };
23 bless $self, $class;
24 return $self; }
25  
26 sub getType {
27 my ($self) = @_;
28 return $$self{type}; }
29  
30 sub getKey {
31 my ($self) = @_;
32 return $$self{key}; }
33  
34 sub getFields {
35 my ($self) = @_;
36 return @{ $$self{fieldlist} }; }
37  
38 sub getField {
39 my ($self, $key) = @_;
40 return $$self{fieldmap}{$key}; }
41  
42 sub getRawField {
43 my ($self, $key) = @_;
44 return $$self{rawfieldmap}{$key}; }
45  
46 sub addField {
47 my ($self, $field, $value) = @_;
48 push(@{ $$self{fieldlist} }, [$field, $value]);
49 $$self{fieldmap}{$field} = $value;
50 return; }
51  
52 sub addRawField {
53 my ($self, $field, $value) = @_;
54 push(@{ $$self{rawfieldlist} }, [$field, $value]);
55 $$self{rawfieldmap}{$field} = $value;
56 return; }
57  
58 sub prettyPrint {
59 my ($self) = @_;
60 return join(",\n",
61 "@" . $$self{type} . "{" . $$self{key},
62 (map { (" " x max(1, (10 - length($$_[0])))) . $$_[0] . " = {" . $$_[1] . "}" }
63 @{ $$self{fieldlist} })
64 ) . "}\n"; }
65  
66 #======================================================================
67 1;