Astro::App::Satpass2::ParseTime::Code - Astro::App::Satpass2 wrapper for custom code to parse time
No user-serviceable parts inside.
This class wraps code to parse a time string and return the epoch.
This class supports the following public methods over and above those documented in its superclass Astro::App::Satpass2::ParseTime.
my $value = $pt->code(); $pt->code( 'my_time_parser' ); $pt->code( 'Some::Package::time_parser' ); $pt->code( sub { ... } ); $pt->code( sub { ... }, 'name_of_record' );
This method acts as both accessor and mutator for the code attribute, which contains the code to do the parsing. Without arguments it is an accessor, returning the value of the attribute.
code
If called with arguments, it sets the value of the attribute. You can pass either the name of the subroutine that implements the parse, or a reference to it. An unqualified name is resolved in the caller's name space.
In general the accessor returns what was set. But if you pass a name of record after the code reference (as in the last example above), that name of record will be returned as the value of the attribute.
The code reference will be called with the following arguments:
That is, it will be called as though it was a method of this class.
If the code has the Verb() attribute (as it will if it comes from a code macro), the options will be as parsed by Getopt::Long using the value of the Verb() attribute as the option specification.
Verb()
If the code does not have the Verb() attribute, the reference will be to an empty hash.
Supported values are discussed below. Any other values are unsupported and reserved by the author.
The arguments depend on the action, as follows:
The argument is the string to parse. The code must return the epoch, or call wail() on the invocant to generate an exception.
must
wail()
This is the only action that must be implemented.
The argument is the time zone being set. The return value is ignored, but the code must call wail() to generate an exception if it does not like the value of the time zone.
If this action has no specific implementation, the code should simply return.
No argument is provided. The code must return a true value if it makes use of the perltime attribute, and a false value otherwise.
perltime
The code reference will be called when the time zone is set (to give the code a chance to reject it), and to request a parse.
In the first case the arguments are ( $self, tz => $zone ), where $self is a reference to this object, and $zone is the prospective new time zone. When called this way the code would reject the zone by calling $self->wail( $some_message ). The code accepts the zone by simply returning.
( $self, tz => $zone )
$self
$zone
$self->wail( $some_message )
In the second case the arguments are ( $self, parse = $string >, where $self is as before, and $string is the string to be parsed. If the parse is successful, the code must return the epoch time. If the parse fails, the code must call wail() as above.
( $self, parse =
$string
You do not need to specify 'code' as an argument to new(), though you can. But you must have set the code before calling inherited method parse_time_absolute().
'code'
new()
Support is by the author. Please file bug reports at https://rt.cpan.org/Public/Dist/Display.html?Name=Astro-App-Satpass2, https://github.com/trwyant/perl-Astro-App-Satpass2/issues, or in electronic mail to the author.
Tom Wyant (wyant at cpan dot org)
Copyright (C) 2016-2024 by Thomas R. Wyant, III
This program is free software; you can redistribute it and/or modify it under the same terms as Perl 5.10.0. For more details, see the full text of the licenses in the directory LICENSES.
This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose.
To install Astro::App::Satpass2, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Astro::App::Satpass2
CPAN shell
perl -MCPAN -e shell install Astro::App::Satpass2
For more information on module installation, please visit the detailed CPAN module installation guide.