| 1 | package Astro::Nova::HMS; | ||||||||||
| 2 | |||||||||||
| 3 | 3 | ▶ | use 5.008; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 3 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 3 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 3 | ▶ | use Astro::Nova; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | # basic stuff is in Astro::Nova's XS! | ||||||||||
| 10 | |||||||||||
| 11 | 0 | ▶ | sub members { | ||||||||
|
Subroutine
members: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 12 | 0 | return qw/hours minutes seconds/ | |||||||||
| 13 | } | ||||||||||
| 14 | |||||||||||
| 15 | 0 | ▶ | sub as_ascii { | ||||||||
|
Subroutine
as_ascii: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 16 | 0 | my $self = shift; | |||||||||
| 17 | 0 | my $template = <<'HERE'; | |||||||||
| 18 | Hours: %d | ||||||||||
| 19 | Minutes: %d | ||||||||||
| 20 | Seconds: %f | ||||||||||
| 21 | HERE | ||||||||||
| 22 | 0 | return sprintf($template, $self->get_all()); | |||||||||
| 23 | } | ||||||||||
| 24 | |||||||||||
| 25 | 0 | ▶ | sub get_all { | ||||||||
|
Subroutine
get_all: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 26 | 0 | my $self = shift; | |||||||||
| 27 | 0 | return(map $self->$_(), map "get_$_", $self->members()); | |||||||||
| 28 | } | ||||||||||
| 29 | |||||||||||
| 30 | 0 | ▶ | sub set_all { | ||||||||
|
Subroutine
set_all: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||
| 31 | 0 | my $self = shift; | |||||||||
| 32 | 0 | foreach my $member (map "set_$_", $self->members) { | |||||||||
| 33 | 0 | ▶ | last if not @_; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 34 | 0 | my $value = shift @_; | |||||||||
| 35 | 0 | ▶ | next if not defined $value; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 36 | 0 | $self->$member($value); | |||||||||
| 37 | } | ||||||||||
| 38 | 0 | return 1; | |||||||||
| 39 | } | ||||||||||
| 40 | |||||||||||
| 41 | 0 | ▶ | sub to_degrees { | ||||||||
|
Subroutine
to_degrees: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 42 | 0 | Astro::Nova::hms_to_deg(shift) | |||||||||
| 43 | } | ||||||||||
| 44 | |||||||||||
| 45 | 0 | ▶ | sub to_radians { | ||||||||
|
Subroutine
to_radians: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 46 | 0 | Astro::Nova::hms_to_rad(shift) | |||||||||
| 47 | } | ||||||||||
| 48 | |||||||||||
| 49 | 1 | ▶ | sub to_dms { | ||||||||
|
Subroutine
to_dms: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 50 | 1 | Astro::Nova::deg_to_dms(Astro::Nova::hms_to_deg(shift)) | |||||||||
| 51 | } | ||||||||||
| 52 | |||||||||||
| 53 | 0 | ▶ | sub from_degrees { | ||||||||
|
Subroutine
from_degrees: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 54 | 0 | my $class = shift; | |||||||||
| 55 | 0 | my $obj = Astro::Nova::deg_to_hms(shift); | |||||||||
| 56 | 0 | ▶ | return $obj if not ref $class; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 57 | 0 | $class->set_all($obj->get_all()); | |||||||||
| 58 | 0 | return $class; | |||||||||
| 59 | } | ||||||||||
| 60 | |||||||||||
| 61 | 0 | ▶ | sub from_radians { | ||||||||
|
Subroutine
from_radians: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 62 | 0 | my $class = shift; | |||||||||
| 63 | 0 | my $obj = Astro::Nova::rad_to_hms(shift); | |||||||||
| 64 | 0 | ▶ | return $obj if not ref $class; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 65 | 0 | $class->set_all($obj->get_all()); | |||||||||
| 66 | 0 | return $class; | |||||||||
| 67 | } | ||||||||||
| 68 | |||||||||||
| 69 | 0 | ▶ | sub from_dms { | ||||||||
|
Subroutine
from_dms: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 70 | 0 | my $class = shift; | |||||||||
| 71 | 0 | my $obj = shift->to_hms(); | |||||||||
| 72 | 0 | ▶ | return $obj if not ref $class; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 73 | 0 | $class->set_all($obj->get_all()); | |||||||||
| 74 | 0 | return $class; | |||||||||
| 75 | } | ||||||||||
| 76 | |||||||||||
| 77 | |||||||||||
| 78 | 3 | 1; | |||||||||
| 79 | __END__ | ||||||||||