File Coverage

blib/lib/Astro/SkyX/ImageLinkResults.pm
Criterion Covered Total %
statement 12 44 27.2
branch 0 12 0.0
condition 0 6 0.0
subroutine 4 9 44.4
pod 0 3 0.0
total 16 74 21.6


line stmt bran cond sub pod time code
1             package Astro::SkyX::ImageLinkResults;
2              
3 1     1   17 use 5.006001;
  1         3  
  1         37  
4 1     1   6 use strict;
  1         2  
  1         28  
5 1     1   6 use warnings;
  1         3  
  1         246  
6             require IO::Socket;
7             require Exporter;
8             require Astro::SkyX;
9              
10             #use vars qw( $SkyXConnection $_count );
11             our @ISA = qw(Exporter );
12              
13             # Items to export into callers namespace by default. Note: do not export
14             # names by default without a very good reason. Use EXPORT_OK instead.
15             # Do not simply export all your public functions/methods/constants.
16             our ($AUTOLOAD);
17             # This allows declaration use SkyX ':all';
18             # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
19             # will save memory.
20             our %EXPORT_TAGS = ( 'all' => [ qw(
21             new connect Send Get
22             ) ] );
23              
24             our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
25              
26             our @EXPORT = qw(
27             );
28              
29             our $VERSION = '0.03';
30             our @PROPERTIES = qw( );
31             our @READWRITEPROPS = qw( );
32             #our @READPROPS = qw( imageScale errorText imageFilePath );
33              
34             # Preloaded methods go here.
35              
36             ##---##
37              
38             sub new {
39 0     0 0   my ($caller, %arg) = @_;
40 0           my $caller_is_obj = ref($caller);
41 0   0       my $class = $caller_is_obj || $caller;
42              
43 0           my $self = bless {
44             _debug => $_[1],
45             }, $class;
46             # Private count increment/decrement methods
47             # $self->_incr_count();
48 0           return $self;
49             }
50             # sub _incr_count { ++$_count }
51             # sub _decr_count { --$_count }
52              
53             sub AUTOLOAD ($;$) {
54 1     1   4 no strict "refs";
  1         1  
  1         451  
55 0     0     my ($self, @newval) = @_;
56 0           my $newtext = '';
57 0           my $js = "/* Java Script */ \r\n";
58 0 0         if ($AUTOLOAD =~ /.*::(.*::.*)/) {
59 0           my $method = $1;
60             # Let's build the javascript
61             # $newtext = join ',', map{ qq/"$_"/ }@newval;
62 0 0         $newtext = join ',', map{ /^[0-9.-]*$/ ? $_ : qq/'$_'/ }@newval;
  0            
63 0           $method =~ tr/::/./s;
64              
65 0           my ($package, $propertyName) = $AUTOLOAD =~ m/^(.+::)(.+)$/;
66 0 0 0       if(haveProperty($propertyName)){
    0          
67 0           $js .= $method . "(" . $newtext . ");\r\n";
68             } elsif(haveReadWriteProp($propertyName) and length($newtext) ){
69              
70 0           $js .= $method . ' = ' . $newtext . ";\r\n";
71             } else {
72 0           $js .= $method . ";\r\n";
73             }
74 0           Astro::SkyX::Send($self,$js);
75 0           return Astro::SkyX::Get($self);
76             }
77 0           die "No such method: $AUTOLOAD";
78             }
79              
80             sub haveReadWriteProp{
81 0     0 0   my ($value) = @_;
82 0           for my $property (@READWRITEPROPS){
83 0 0         if($property eq $value){
84 0           return "1";
85             }
86             }
87 0           return undef;
88             }
89              
90             sub haveProperty{
91 0     0 0   my ($value) = @_;
92 0           for my $property (@PROPERTIES){
93 0 0         if($property eq $value){
94 0           return "1";
95             }
96             }
97 0           return undef;
98             }
99              
100 0     0     sub DESTROY {
101             # $_[0]->_decr_count();
102             }
103              
104             1;
105             __END__