| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | # --8<--8<--8<--8<-- | 
| 2 |  |  |  |  |  |  | # | 
| 3 |  |  |  |  |  |  | # Copyright (C) 2007 Smithsonian Astrophysical Observatory | 
| 4 |  |  |  |  |  |  | # | 
| 5 |  |  |  |  |  |  | # This file is part of Astro::NED::Query | 
| 6 |  |  |  |  |  |  | # | 
| 7 |  |  |  |  |  |  | # Astro::NED::Query is free software: you can redistribute it and/or modify | 
| 8 |  |  |  |  |  |  | # it under the terms of the GNU General Public License as published by | 
| 9 |  |  |  |  |  |  | # the Free Software Foundation, either version 3 of the License, or (at | 
| 10 |  |  |  |  |  |  | # your option) any later version. | 
| 11 |  |  |  |  |  |  | # | 
| 12 |  |  |  |  |  |  | # This program is distributed in the hope that it will be useful, | 
| 13 |  |  |  |  |  |  | # but WITHOUT ANY WARRANTY; without even the implied warranty of | 
| 14 |  |  |  |  |  |  | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
| 15 |  |  |  |  |  |  | # GNU General Public License for more details. | 
| 16 |  |  |  |  |  |  | # | 
| 17 |  |  |  |  |  |  | # You should have received a copy of the GNU General Public License | 
| 18 |  |  |  |  |  |  | # along with this program.  If not, see . | 
| 19 |  |  |  |  |  |  | # | 
| 20 |  |  |  |  |  |  | # -->8-->8-->8-->8-- | 
| 21 |  |  |  |  |  |  |  | 
| 22 |  |  |  |  |  |  | package Astro::NED::Response::CoordExtinct; | 
| 23 |  |  |  |  |  |  |  | 
| 24 | 1 |  |  | 1 |  | 19 | use 5.006; | 
|  | 1 |  |  |  |  | 3 |  | 
|  | 1 |  |  |  |  | 45 |  | 
| 25 | 1 |  |  | 1 |  | 6 | use strict; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 42 |  | 
| 26 | 1 |  |  | 1 |  | 6 | use warnings; | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 57 |  | 
| 27 |  |  |  |  |  |  |  | 
| 28 | 1 |  |  | 1 |  | 1178 | use Regexp::Common; | 
|  | 1 |  |  |  |  | 6247 |  | 
|  | 1 |  |  |  |  | 7 |  | 
| 29 |  |  |  |  |  |  |  | 
| 30 |  |  |  |  |  |  | our $VERSION = '0.30'; | 
| 31 |  |  |  |  |  |  |  | 
| 32 | 1 |  |  | 1 |  | 134174 | use base qw/ Class::Accessor /; | 
|  | 1 |  |  |  |  | 3 |  | 
|  | 1 |  |  |  |  | 1187 |  | 
| 33 |  |  |  |  |  |  |  | 
| 34 |  |  |  |  |  |  | my @Bandpasses = qw/ U B V R I J H K L' /; | 
| 35 |  |  |  |  |  |  |  | 
| 36 |  |  |  |  |  |  | my @Fields = ( qw/ RA Dec Lat Lon PA EB-V/, @Bandpasses ); | 
| 37 |  |  |  |  |  |  |  | 
| 38 |  |  |  |  |  |  | __PACKAGE__->mk_ro_accessors( @Fields ); | 
| 39 |  |  |  |  |  |  |  | 
| 40 |  |  |  |  |  |  | # Preloaded methods go here. | 
| 41 |  |  |  |  |  |  |  | 
| 42 |  |  |  |  |  |  | sub dump | 
| 43 |  |  |  |  |  |  | { | 
| 44 | 0 |  |  | 0 | 1 | 0 | my ( $self, $fh )  = @_; | 
| 45 |  |  |  |  |  |  |  | 
| 46 | 0 | 0 |  |  |  | 0 | $fh = \*STDOUT unless defined $fh; | 
| 47 |  |  |  |  |  |  |  | 
| 48 | 0 |  |  |  |  | 0 | print {$fh} "$_: ", defined $self->get($_) ? $self->get($_) : 'undef', "\n" | 
| 49 | 0 | 0 |  |  |  | 0 | foreach @Fields; | 
| 50 |  |  |  |  |  |  |  | 
| 51 | 0 |  |  |  |  | 0 | return; | 
| 52 |  |  |  |  |  |  | } | 
| 53 |  |  |  |  |  |  |  | 
| 54 |  |  |  |  |  |  | sub fields | 
| 55 |  |  |  |  |  |  | { | 
| 56 | 0 |  |  | 0 | 1 | 0 | my ( $self ) = @_; | 
| 57 |  |  |  |  |  |  |  | 
| 58 |  |  |  |  |  |  | # object method | 
| 59 | 0 | 0 |  |  |  | 0 | if ( ref $self ) | 
| 60 |  |  |  |  |  |  | { | 
| 61 | 0 |  |  |  |  | 0 | return grep { defined $self->get($_) } @Fields | 
|  | 0 |  |  |  |  | 0 |  | 
| 62 |  |  |  |  |  |  | } | 
| 63 |  |  |  |  |  |  |  | 
| 64 |  |  |  |  |  |  | # class method | 
| 65 |  |  |  |  |  |  | else | 
| 66 |  |  |  |  |  |  | { | 
| 67 | 0 |  |  |  |  | 0 | return @Fields; | 
| 68 |  |  |  |  |  |  | } | 
| 69 |  |  |  |  |  |  | } | 
| 70 |  |  |  |  |  |  |  | 
| 71 |  |  |  |  |  |  | sub data | 
| 72 |  |  |  |  |  |  | { | 
| 73 | 1 |  |  | 1 | 1 | 1403 | my ( $self ) = @_; | 
| 74 |  |  |  |  |  |  |  | 
| 75 | 1 |  |  |  |  | 3 | return %{$self}; | 
|  | 1 |  |  |  |  | 35 |  | 
| 76 |  |  |  |  |  |  | } | 
| 77 |  |  |  |  |  |  |  | 
| 78 |  |  |  |  |  |  | sub parseHTML | 
| 79 |  |  |  |  |  |  | { | 
| 80 | 1 |  |  | 1 | 1 | 3 | my $self = shift; | 
| 81 |  |  |  |  |  |  |  | 
| 82 | 1 |  |  |  |  | 14 | require HTML::Parser; | 
| 83 | 1 |  |  |  |  | 3 | my $text; | 
| 84 | 1 |  |  |  |  | 12 | my $p = HTML::Parser->new; | 
| 85 | 1 |  |  | 5 |  | 155 | $p->handler( text => sub { $text .= $_[0] }, 'dtext' ); | 
|  | 5 |  |  |  |  | 315 |  | 
| 86 | 1 |  |  |  |  | 6 | $p->handler( start => '' ); | 
| 87 | 1 |  |  |  |  | 89 | $p->handler( end => '' ); | 
| 88 | 1 |  |  |  |  | 6 | $p->unbroken_text(1); | 
| 89 | 1 |  |  |  |  | 44 | $p->parse( $_[0] ); | 
| 90 | 1 |  |  |  |  | 37 | $p->eof; | 
| 91 |  |  |  |  |  |  |  | 
| 92 | 1 |  |  |  |  | 25 | $self->{'EB-V'} = $text =~ /E\(B-V\)\s*=\s*(.*)\s+mag/; | 
| 93 |  |  |  |  |  |  |  | 
| 94 |  |  |  |  |  |  |  | 
| 95 | 1 |  |  |  |  | 5 | for my $bandpass ( @Bandpasses ) | 
| 96 |  |  |  |  |  |  | { | 
| 97 | 9 |  |  |  |  | 3334 | ( $self->{$bandpass} ) = | 
| 98 |  |  |  |  |  |  | $text =~ /^$bandpass\s*\(.*\)\s+($RE{num}{real})/m; | 
| 99 |  |  |  |  |  |  | } | 
| 100 |  |  |  |  |  |  |  | 
| 101 | 1 |  |  |  |  | 176 | @{$self}{qw/ Lat Lon PA/} = | 
|  | 1 |  |  |  |  | 1243 |  | 
| 102 |  |  |  |  |  |  | $text =~ /^Output:.*\n+ | 
| 103 |  |  |  |  |  |  | ($RE{num}{real})\s+ | 
| 104 |  |  |  |  |  |  | ($RE{num}{real})\s+ | 
| 105 |  |  |  |  |  |  | ($RE{num}{real})/mx; | 
| 106 |  |  |  |  |  |  |  | 
| 107 | 1 |  |  |  |  | 32 | $self->{RA}  = $self->{Lat}; | 
| 108 | 1 |  |  |  |  | 5 | $self->{Dec} = $self->{Lon}; | 
| 109 |  |  |  |  |  |  |  | 
| 110 | 1 |  |  |  |  | 42 | return; | 
| 111 |  |  |  |  |  |  | } | 
| 112 |  |  |  |  |  |  |  | 
| 113 |  |  |  |  |  |  | 1; | 
| 114 |  |  |  |  |  |  | __END__ |