Geo-Region
view release on metacpan or search on metacpan
lib/Geo/Region.pm view on Meta::CPAN
package Geo::Region;
use v5.8.1;
use utf8;
use Carp qw( carp );
use Scalar::Util qw( looks_like_number weaken );
use List::Util qw( all any );
use Moo;
our $VERSION = '0.07';
my %children_of = (
# regions of subregions
'001' => [qw( 002 009 019 142 150 )],
'002' => [qw( 011 014 015 017 018 )],
'003' => [qw( 013 021 029 )],
lib/Geo/Region.pm view on Meta::CPAN
: ()
} @_ };
my %excludes = map { $_ => 1 }
$build_children->(@{$self->_excludes});
my %children = map { $_ => 1 }
grep { !exists $excludes{$_} }
$build_children->(@{$self->_includes});
weaken $build_children;
return \%children;
},
);
has _parents => (
is => 'lazy',
builder => sub {
my @regions = @{shift->_includes};
my ($build_parents, %count);
lib/Geo/Region.pm view on Meta::CPAN
my $region = $_;
$region, $build_parents->(grep {
any { $_ eq $region } @{$children_of{$_}}
} keys %children_of);
} @_ };
my %parents = map { $_ => 1 }
grep { ++$count{$_} == @regions }
$build_parents->(@regions);
weaken $build_parents;
return \%parents;
},
);
has _countries => (
is => 'lazy',
builder => sub { [
sort
grep { /^[A-Z]{2}$/ && !exists $noncountries{$_} }
keys %{shift->_children}
( run in 0.732 second using v1.01-cache-2.11-cpan-65fba6d93b7 )