| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Astro::VEX; | 
| 2 |  |  |  |  |  |  |  | 
| 3 |  |  |  |  |  |  | =head1 NAME | 
| 4 |  |  |  |  |  |  |  | 
| 5 |  |  |  |  |  |  | Astro::VEX - VEX (VLBI Experiment Definition) file handling module | 
| 6 |  |  |  |  |  |  |  | 
| 7 |  |  |  |  |  |  | =cut | 
| 8 |  |  |  |  |  |  |  | 
| 9 | 2 |  |  | 2 |  | 1312 | use strict; | 
|  | 2 |  |  |  |  | 4 |  | 
|  | 2 |  |  |  |  | 55 |  | 
| 10 | 2 |  |  | 2 |  | 9 | use warnings; | 
|  | 2 |  |  |  |  | 3 |  | 
|  | 2 |  |  |  |  | 79 |  | 
| 11 |  |  |  |  |  |  |  | 
| 12 |  |  |  |  |  |  | our $VERSION = '0.001'; | 
| 13 |  |  |  |  |  |  |  | 
| 14 | 2 |  |  | 2 |  | 9 | use overload '""' => 'stringify'; | 
|  | 2 |  |  |  |  | 2 |  | 
|  | 2 |  |  |  |  | 13 |  | 
| 15 |  |  |  |  |  |  |  | 
| 16 |  |  |  |  |  |  | sub new { | 
| 17 | 2 |  | 33 | 2 | 0 | 1277 | my $proto = shift; my $class = ref($proto) || $proto; | 
|  | 2 |  |  |  |  | 14 |  | 
| 18 | 2 |  |  |  |  | 8 | my %opt = @_; | 
| 19 |  |  |  |  |  |  |  | 
| 20 | 2 | 100 |  |  |  | 7 | if (exists $opt{'text'}) { | 
| 21 | 1 |  |  |  |  | 7 | require Astro::VEX::Parse; | 
| 22 | 1 |  |  |  |  | 4 | return Astro::VEX::Parse->parse_vex($opt{'text'}); | 
| 23 |  |  |  |  |  |  | } | 
| 24 |  |  |  |  |  |  |  | 
| 25 |  |  |  |  |  |  | return bless { | 
| 26 |  |  |  |  |  |  | VERSION => $opt{'version'} // '1.5', | 
| 27 | 1 |  | 50 |  |  | 23 | CONTENT => $opt{'content'} // [], | 
|  |  |  | 50 |  |  |  |  | 
| 28 |  |  |  |  |  |  | }, $class; | 
| 29 |  |  |  |  |  |  | } | 
| 30 |  |  |  |  |  |  |  | 
| 31 |  |  |  |  |  |  | sub block { | 
| 32 | 1 |  |  | 1 | 0 | 526 | my $self = shift; | 
| 33 | 1 |  |  |  |  | 3 | my $name = shift; | 
| 34 |  |  |  |  |  |  |  | 
| 35 | 1 |  |  |  |  | 1 | for my $item (@{$self->{'CONTENT'}}) { | 
|  | 1 |  |  |  |  | 3 |  | 
| 36 | 1 | 50 |  |  |  | 9 | if ($item->isa('Astro::VEX::Block')) { | 
| 37 | 1 | 50 |  |  |  | 4 | if ($item->name eq $name) { | 
| 38 | 1 |  |  |  |  | 7 | return $item; | 
| 39 |  |  |  |  |  |  | } | 
| 40 |  |  |  |  |  |  | } | 
| 41 |  |  |  |  |  |  | } | 
| 42 |  |  |  |  |  |  |  | 
| 43 | 0 |  |  |  |  | 0 | die 'Block not found: ' . $name; | 
| 44 |  |  |  |  |  |  | } | 
| 45 |  |  |  |  |  |  |  | 
| 46 |  |  |  |  |  |  | sub stringify { | 
| 47 | 1 |  |  | 1 | 0 | 1191 | my $self = shift; | 
| 48 |  |  |  |  |  |  |  | 
| 49 | 1 |  |  |  |  | 4 | return join "\n", 'VEX_rev = ' . $self->{'VERSION'} . ';', @{$self->{'CONTENT'}}, ''; | 
|  | 1 |  |  |  |  | 36 |  | 
| 50 |  |  |  |  |  |  | } | 
| 51 |  |  |  |  |  |  |  | 
| 52 |  |  |  |  |  |  | 1; | 
| 53 |  |  |  |  |  |  |  | 
| 54 |  |  |  |  |  |  | __END__ |