SIMBAD/Result/Object.pm

filter: Statementstmt 61.0% 58 / 95 Branchbran 52.3% 22 / 42 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 60.0% 12 / 20 Podpod 100% 18 / 18 totaltotal 61.6% 111 / 180 CC 23 SCAR 13.4
CC
23
Cov
58%
target
6.0
bmag
6.0
vmag
6.0
CRAP 3.8
« SIMBAD/Query.pm ↑ Summary SIMBAD/Result.pm »
1 package Astro::SIMBAD::Result::Object;
2  
3 # ---------------------------------------------------------------------------
4  
5 #+
6 # Name:
7 # Astro::SIMBAD::Result:Object
8  
9 # Purposes:
10 # Perl wrapper for the SIMBAD database
11  
12 # Language:
13 # Perl module
14  
15 # Description:
16 # This module wraps the SIMBAD online database.
17  
18 # Authors:
19 # Alasdair Allan (aa@astro.ex.ac.uk)
20  
21 # Revision:
22 # $Id: Object.pm,v 1.3 2005/06/08 01:38:17 aa Exp $
23  
24 # Copyright:
25 # Copyright (C) 2001 University of Exeter. All Rights Reserved.
26  
27 #-
28  
29 # ---------------------------------------------------------------------------
30  
31 =head1 NAME
32  
33 Astro::SIMBAD::Result::Object - A individual astronomical object
34  
35 =head1 SYNOPSIS
36  
37 $object = new Astro::SIMBAD::Result::Object( Name => $object_name,
38 Type => $object_type,
39 Long => $long_type,
40 Frame => \@coord_frame,
41 RA => $ra,
42 Dec => $declination,
43 Spec => $spectral_type,
44 URL => $url );
45  
46 =head1 DESCRIPTION
47  
48 Stores meta-data about an individual astronomical object in the
49 Astro::SIMBAD::Result object returned by an Astro::SIMBAD::Query object.
50  
51 =cut
52  
53 # L O A D M O D U L E S --------------------------------------------------
54  
55 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
56 3 ▶use vars qw/ $VERSION /;
Subroutine BEGIN: called CC=1 SCAR=0.0
57  
58 3 ▶'$Revision: 1.3 $ ' =~ /.*:\s(.*)\s\$/ && ($VERSION = $1);
Branch: 1 branch
BranchTrueFalseTotal
"\$Revision: 1.3 \$ " =~ /.*:\s(.*)\s\$/ and $Astro::SIMBAD::Result::Object::VERSION = $1 3 0 3
59  
60 # C O N S T R U C T O R ----------------------------------------------------
61  
62 =head1 REVISION
63  
64 $Id: Object.pm,v 1.3 2005/06/08 01:38:17 aa Exp $
65  
66 =head1 METHODS
67  
68 =head2 Constructor
69  
70 =over 4
71  
72 =item B<new>
73  
74 Create a new instance from a hash of options
75  
76 $paper = new Astro::SIMBAD::Result::Object( );
77  
78 returns a reference to an SIMBAD astronomical object.
79  
80 =cut
81  
82 6 ▶sub new {
Subroutine new: called CC=3 SCAR=11.8
Pod documented
83 6 my $proto = shift;
84 6 ▶ my $class = ref($proto) || $proto;
Condition33%1/3
ref $proto || $proto
l!l&&r!l&&!r
060
MC/DC0%0/2
ref $proto || $proto
ref $proto $proto
Truth table33%1/3
A || B
A= ref $protoB= $proto
ABresult
1X1
011
000
85  
86 # bless the query hash into the class
87 6 my $block = bless { NAME => undef,
88 TARGET => undef,
89 TYPE => undef,
90 LONG => undef,
91 FRAME => [],
92 RA => undef,
93 DEC => undef,
94 SPEC => undef,
95 URL => undef,
96 BMAG => undef,
97 VMAG => undef,
98 IDENT => [],
99 PM => [],
100 PLX => undef,
101 RADIAL => undef,
102 REDSHIFT=> undef,
103 }, $class;
104  
105 # If we have arguments configure the object
106 6 ▶ $block->configure( @_ ) if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 6 0 6
107  
108 6 return $block;
109  
110 }
111  
112 # A C C E S S O R --------------------------------------------------------
113  
114 =back
115  
116 =head2 Accessor Methods
117  
118 =over 4
119  
120 =item B<name>
121  
122 Return (or set) the name of the object
123  
124 $name = $object->name();
125 $object->name( $name );
126  
127 Query types: list, object
128  
129 =cut
130  
131 12 ▶sub name {
Subroutine name: called CC=2 SCAR=6.9
Pod documented
132 12 my $self = shift;
133 12 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 6 6 12
134 6 $self->{NAME} = shift;
135 }
136 12 return $self->{NAME};
137 }
138  
139 =item B<target>
140  
141 Return (or set) the target name of the object. Available whenever a target is
142 specified in the query. The returned value is identical to the query parameter,
143 except that it is normalized (spaces replaced with '+' characters).
144 This is useful because name() may return a different designation than the
145 target that is supplied as a query parameter.
146  
147 $target = $object->target();
148 $object->target( $target );
149  
150 Query types: list, object
151  
152 =cut
153  
154 0 ▶sub target {
Subroutine target: not called CC=2 SCAR=17.9
Pod documented
155 0 my $self = shift;
156 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
157 0 $self->{TARGET} = shift;
158 }
159 0 return $self->{TARGET};
160 }
161  
162 =item B<type>
163  
164 Return (or set) the (short) type of the object
165  
166 $type = $object->type();
167 $object->type( $type );
168  
169 Query types: list
170  
171 =cut
172  
173 9 ▶sub type {
Subroutine type: called CC=2 SCAR=6.9
Pod documented
174 9 my $self = shift;
175 9 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 6 3 9
176 6 $self->{TYPE} = shift;
177 }
178 9 return $self->{TYPE};
179 }
180  
181 =item B<long>
182  
183 Return (or set) the (long) type of the object
184  
185 $long_type = $object->long();
186 $object->long( $long_type );
187  
188 Query types: list, object
189  
190 =cut
191  
192 9 ▶sub long {
Subroutine long: called CC=2 SCAR=6.9
Pod documented
193 9 my $self = shift;
194 9 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 6 3 9
195 6 $self->{LONG} = shift;
196 }
197 9 return $self->{LONG};
198 }
199  
200 =item B<frame>
201  
202 Return (or set) the system the R.A. and DEC stored in the object are
203 defined in, e.g. Co-ordinate Frame FK5, Epoch 1950 and Equinox 2000
204  
205 @system = $object->frame();
206 $object->frame( \@system );
207  
208 where @system would be [ "FK5", 1950.0, 2000.0 ]. If called in a scalar
209 context will return a string of the form "FK5 1950/2000" to
210  
211 Query types: list, object
212  
213 =cut
214  
215 9 ▶sub frame {
Subroutine frame: called CC=3 SCAR=11.0
Pod documented
216 9 my $self = shift;
217  
218 9 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 6 3 9
219 # take a local copy to avoid "copy of copy" problems
220 6 my $frame = shift;
221 6 @{$self->{FRAME}} = @{$frame};
222 }
223
224 9 my $stringify =
225 9 "${$self->{FRAME}}[0] ${$self->{FRAME}}[1]/${$self->{FRAME}}[2]";
226
227 0 ▶ return wantarray ? @{$self->{FRAME}} : $stringify;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 9 9
228 }
229  
230 =item B<ra>
231  
232 Return (or set) the R.A. of the object
233  
234 $ra = $object->ra();
235 $object->ra( $ra );
236  
237 Query types: list, object
238  
239 =cut
240  
241 9 ▶sub ra {
Subroutine ra: called CC=2 SCAR=6.9
Pod documented
242 9 my $self = shift;
243 9 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 6 3 9
244 6 $self->{RA} = shift;
245 }
246 9 return $self->{RA};
247 }
248  
249 =item B<dec>
250  
251 Return (or set) the Declination of the object
252  
253 $dec = $object->dec();
254 $object->dec( $dec );
255  
256 Query types: list, object
257  
258 =cut
259  
260 9 ▶sub dec {
Subroutine dec: called CC=2 SCAR=6.9
Pod documented
261 9 my $self = shift;
262 9 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 6 3 9
263 6 $self->{DEC} = shift;
264 }
265 9 return $self->{DEC};
266 }
267  
268 =item B<spec>
269  
270 Return (or set) the Spectral Type of the object
271  
272 $spec_type = $object->spec();
273 $object->spec( $spec_type );
274  
275 Query types: list, object
276  
277 =cut
278  
279 9 ▶sub spec {
Subroutine spec: called CC=2 SCAR=6.9
Pod documented
280 9 my $self = shift;
281 9 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 6 3 9
282 6 $self->{SPEC} = shift;
283 }
284 9 return $self->{SPEC};
285 }
286  
287 =item B<url>
288  
289 Return (or set) the followup URL for the object where more information
290 can be found via SIMBAD, including pointers to reduced data.
291  
292 $url = $object->url();
293 $object->url( $url );
294  
295 =cut
296  
297 6 ▶sub url {
Subroutine url: called CC=2 SCAR=6.9
Pod documented
298 6 my $self = shift;
299 6 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 3 3 6
300 3 $self->{URL} = shift;
301 }
302 6 return $self->{URL};
303 }
304  
305 =item B<bmag>
306  
307 Return (or set) the B-magnitude of the object
308  
309 $bmag = $object->bmag();
310 $object->bmag( $bmag );
311  
312 Query types: list, object
313  
314 =cut
315  
316 0 ▶sub bmag {
Subroutine bmag: not called CC=2 SCAR=17.9
Pod documented
317 0 my $self = shift;
318 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
319 0 $self->{BMAG} = shift;
320 }
321 0 return $self->{BMAG};
322 }
323  
324 =item B<vmag>
325  
326 Return (or set) the V-magnitude of the object
327  
328 $vmag = $object->vmag();
329 $object->vmag( $vmag );
330  
331 Query types: list, object
332  
333 =cut
334  
335 0 ▶sub vmag {
Subroutine vmag: not called CC=2 SCAR=17.9
Pod documented
336 0 my $self = shift;
337 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
338 0 $self->{VMAG} = shift;
339 }
340 0 return $self->{VMAG};
341 }
342  
343 =item B<ident>
344  
345 Return (or append) the array of object identifiers
346  
347 @ident = $object->ident();
348 $object->ident( @ident );
349  
350 Query types: object
351  
352 =cut
353  
354 0 ▶sub ident {
Subroutine ident: not called CC=2 SCAR=17.9
Pod documented
355 0 my $self = shift;
356 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
357 0 my $idarray = shift;
358 0 @{$self->{IDENT}} = @{$idarray};
359 }
360 0 return $self->{IDENT};
361 }
362  
363 =item B<pm>
364  
365 Return (or set) the proper motion of the object in mas/year
366  
367 @pm = $object->pm();
368 $object->pm( @pm );
369  
370 Query types: object
371  
372 =cut
373  
374 0 ▶sub pm {
Subroutine pm: not called CC=2 SCAR=17.9
Pod documented
375 0 my $self = shift;
376 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
377 0 push @{$self->{PM}}, @_[0..1];
378 }
379 0 return $self->{PM};
380 }
381  
382 =item B<plx>
383  
384 Return (or set) the parallax of the object
385  
386 $plx = $object->plx();
387 $object->plx( $plx );
388  
389 Query types: object
390  
391 =cut
392  
393 0 ▶sub plx {
Subroutine plx: not called CC=2 SCAR=17.9
Pod documented
394 0 my $self = shift;
395 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
396 0 $self->{PLX} = shift;
397 }
398 0 return $self->{PLX};
399 }
400  
401 =item B<radial>
402  
403 Return (or set) the radial velocity (km/s) of the object
404  
405 $radial = $object->radial();
406 $object->radial( $radial );
407  
408 Query types: object
409  
410 =cut
411  
412 0 ▶sub radial {
Subroutine radial: not called CC=2 SCAR=17.9
Pod documented
413 0 my $self = shift;
414 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
415 0 $self->{RADIAL} = shift;
416 }
417 0 return $self->{RADIAL};
418 }
419  
420 =item B<redshift>
421  
422 Return (or set) the redshift of the object
423  
424 $redshift = $object->redshift();
425 $object->redshift( $redshift );
426  
427 Query types: object
428  
429 =cut
430  
431 0 ▶sub redshift {
Subroutine redshift: not called CC=2 SCAR=17.9
Pod documented
432 0 my $self = shift;
433 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
434 0 $self->{REDSHIFT} = shift;
435 }
436 0 return $self->{REDSHIFT};
437 }
438  
439 # C O N F I G U R E -------------------------------------------------------
440  
441 =back
442  
443 =head2 General Methods
444  
445 =over 4
446  
447 =item B<configure>
448  
449 Configures the object from multiple pieces of information.
450  
451 $object->configure( %options );
452  
453 Takes a hash as argument with the following keywords:
454  
455 =cut
456  
457 6 ▶sub configure {
Subroutine configure: called CC=4 SCAR=13.9
Pod documented
458 6 my $self = shift;
459  
460 # return unless we have arguments
461 6 ▶ return undef unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 0 6 6
462  
463 # grab the argument list
464 6 my %args = @_;
465  
466 # Loop over the allowed keys storing the values
467 # in the object if they exist
468 6 for my $key (qw / Name Type Long Frame RA Dec Spec URL /) {
469 48 my $method = lc($key);
470 48 ▶ $self->$method( $args{$key} ) if exists $args{$key};
Branch: 1 branch
BranchTrueFalseTotal
if exists $args{$key} 45 3 48
471 }
472  
473 }
474  
475  
476 # T I M E A T T H E B A R --------------------------------------------
477  
478 =back
479  
480 =head1 COPYRIGHT
481  
482 Copyright (C) 2001 University of Exeter. All Rights Reserved.
483  
484 This program was written as part of the eSTAR project and is free software;
485 you can redistribute it and/or modify it under the terms of the GNU Public
486 License.
487  
488  
489 =head1 AUTHORS
490  
491 Alasdair Allan E<lt>aa@astro.ex.ac.ukE<gt>,
492  
493 =cut
494  
495 # L A S T O R D E R S ------------------------------------------------------
496  
497 3 1;
« SIMBAD/Query.pm ↑ Summary SIMBAD/Result.pm »