| Geography-JapanesePrefectures-Walker documentation | Contained in the Geography-JapanesePrefectures-Walker distribution. |
Geography::JapanesePrefectures::Walker - Geography::JapanesePrefectures's wrappers.
in your script:
use Geography::JapanesePrefectures::Walker;
my $g = Geography::JapanesePrefectures::Walker->new('euc-jp');
my $prefs = $g->prefectures;
create Geography::JapanesePrefectures::Walker's object.
privete method. this method encode all data.
This method get Geography::JapanesePrefectures's all data.
This method get Geography::JapanesePrefectures's all data.
This method get Geography::JapanesePrefectures's name data for id.
This method get Geography::JapanesePrefectures's name data.
This method get Geography::JapanesePrefectures's region data.
This method get Geography::JapanesePrefectures's name data for region.
This method get Geography::JapanesePrefectures's id data for name.
Geography::JapanesePrefectures
Plagger::Walker
The authors of Plagger::Walker, from which a lot of code was used.
id:tokuhirom
Atsushi Kobayashi, <nekokak at gmail.com>
Please report any bugs or feature requests to
bug-geography-japaneseprefectures-walker at rt.cpan.org, or through the web interface at
http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Geography-JapanesePrefectures-Walker.
I will be notified, and then you'll automatically be notified of progress on
your bug as I make changes.
You can find documentation for this module with the perldoc command.
perldoc Geography::JapanesePrefectures::Walker
You can also look for information at:
http://annocpan.org/dist/Geography-JapanesePrefectures-Walker
http://cpanratings.perl.org/d/Geography-JapanesePrefectures-Walker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Geography-JapanesePrefectures-Walker
http://search.cpan.org/dist/Geography-JapanesePrefectures-Walker
Copyright 2006 Atsushi Kobayashi, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| Geography-JapanesePrefectures-Walker documentation | Contained in the Geography-JapanesePrefectures-Walker distribution. |
package Geography::JapanesePrefectures::Walker; use strict; use warnings; use Carp; use Scalar::Util qw(blessed); use Encode; use List::MoreUtils qw/uniq firstval/; use Geography::JapanesePrefectures; use Data::Visitor::Callback; our $VERSION = '0.02'; sub new { my $class = shift; my $param = { encoding => shift || 'utf8', }; my $self = bless $param, $class; $self->{_geo_data} = $self->_encode_prefectures_infos; $self; } sub _encode_prefectures_infos { my $self = shift; my $prefs = Geography::JapanesePrefectures->prefectures_infos; my $visitor = Data::Visitor::Callback->new( plain_value => sub { Encode::from_to($_, 'utf8', $self->{encoding}, 1); } ); $visitor->visit($prefs); return $prefs; } sub prefectures_infos { shift->{_geo_data} } sub prefectures { my $self = shift; return [ map { { id => $_->{id} , name => $_->{name}, region => $_->{region}, } } @{ $self->prefectures_infos } ]; } sub prefectures_name_for_id { my ($self, $id) = @_; my $pref = firstval { $_->{id} } grep { $_->{id} eq $id } @{ $self->prefectures_infos }; return $pref->{name}; } sub prefectures_name { my $self = shift; return map { $_->{name} } @{ $self->prefectures_infos }; } sub prefectures_regions { my $self = shift; return uniq map { $_->{region} } @{ $self->prefectures_infos }; } sub prefectures_name_for_region { my ($self, $region) = @_; return map { $_->{name} } grep { $_->{region} eq $region } @{ $self->prefectures_infos }; } sub prefectures_id_for_name { my ($self, $name) = @_; my $pref = firstval { $_->{id} } grep { $_->{name} eq $name } @{ $self->prefectures_infos }; return $pref->{id}; }
1; # End of Geography::JapanesePrefectures::Walker