| 1 | package Geo::Formatter::FormatBase::Single; | ||
| 2 | |||
| 3 | use warnings; | ||
| 4 | use strict; | ||
| 5 | use Carp; | ||
| 6 | |||
| 7 | use version; our $VERSION = qv('0.0.1'); | ||
| 8 | use base qw(Geo::Formatter::FormatBase); | ||
| 9 | |||
| 10 | sub enc_wrap { | ||
| 11 | my $pkg = shift; | ||
| 12 | |||
| 13 | return $pkg->can("encode") ? sub { | ||
| 14 | if (@_ < 2) { | ||
| 15 | croak "Latitude and Longitude are neccesary"; | ||
| 16 | } elsif (@_ > 3) { | ||
| 17 | croak "Too many arguments"; | ||
| 18 | } elsif (@_ == 3 && ref($_[2]) ne "HASH") { | ||
| 19 | croak "Option value must be hash reference"; | ||
| 20 | } | ||
| 21 | |||
| 22 | return $pkg->encode(@_); | ||
| 23 | } : undef; | ||
| 24 | } | ||
| 25 | |||
| 26 | sub dec_wrap { | ||
| 27 | my $pkg = shift; | ||
| 28 | |||
| 29 | return $pkg->can("decode") ? sub { | ||
| 30 | if (@_ < 1) { | ||
| 31 | croak "Format string is neccesary"; | ||
| 32 | } elsif (@_ > 2) { | ||
| 33 | croak "Too many arguments"; | ||
| 34 | } elsif (@_ == 2 && ref($_[1]) ne "HASH") { | ||
| 35 | croak "Option value must be hash reference"; | ||
| 36 | } | ||
| 37 | |||
| 38 | my @ret = $pkg->decode(@_); | ||
| 39 | |||
| 40 | wantarray ? @ret : \@ret; | ||
| 41 | } : undef; | ||
| 42 | } | ||
| 43 | |||
| 44 | 1; | ||
| 45 | |||
| 46 | __END__ |