| Geo-Direction-Name-Spec-Chinese documentation | Contained in the Geo-Direction-Name-Spec-Chinese distribution. |
Geo::Direction::Name::Spec::Chinese - Add chinese traditional direction specification to Geo::Direction::Name
# After install this module:
use Geo::Direction::Name;
my $dirn = Geo::Direction::Name->new({spec=>'chinese',locale=>'ja_JP'});
my $dir = $dirn->from_string('q');
# 0.000
my $str = $dirn->to_string(45.0,{ devide => 8 });
#
Geo::Direction::Name::Spec::Chinese adds chinese traditional direction specification to Geo::Direction::Name.
Chinese traditional direction has some variation of specification, so this module select specification by deviding number of direction.
Deviding number is 8. You can see information of Bagua specification in http://en.wikipedia.org/wiki/Bagua_(concept).
Deviding number is 12. You can see information of Dizhi specification in http://en.wikipedia.org/wiki/Dizhi.
Deviding number is 24. Combined Bagua, Dizhi, and Tiangan specifications. You can see information of Tiangan specification in http://en.wikipedia.org/wiki/Celestial_stem.
OHTSUKA Ko-hei <nene@kokogiko.net>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| Geo-Direction-Name-Spec-Chinese documentation | Contained in the Geo-Direction-Name-Spec-Chinese distribution. |
package Geo::Direction::Name::Spec::Chinese; use strict; use warnings; use Carp; use version; our $VERSION = qv('0.0.1'); use Geo::Direction::Name::Spec::Dizhi; use Geo::Direction::Name::Spec::Bagua; BEGIN { if ( $] >= 5.006 ) { require utf8; import utf8; } } sub allowed_dev { qw(8 12 24) } sub default_dev { 8 } sub new { my $class = shift; my $self = bless { }, $class; foreach my $spec (qw(dizhi bagua)) { my $sclass = "Geo::Direction::Name::Spec::" .ucfirst("$spec"); $self->{"spec_$spec"} = $sclass->new; } $self; } sub locale { my $self = shift; my @locales; foreach my $spec (qw(dizhi bagua)) { my $spec_o = $self->{"spec_$spec"}; push ( @locales, $spec_o->locale(@_) ); } \@locales; } sub to_string { my $self = shift; my $option = $_[1] || {}; my $devide = $option->{devide} || $self->default_dev; croak ("Devide parameter must be ". join( ",", $self->allowed_dev ) ) unless ( grep { $devide == $_ } $self->allowed_dev ); my $spec_o = $devide == 8 ? $self->{'spec_bagua'} : $self->{'spec_dizhi'}; $spec_o->to_string(@_); } sub from_string { my $self = shift; my $dizhi = $self->{'spec_dizhi'}->from_string(@_); defined($dizhi) ? $dizhi : $self->{'spec_bagua'}->from_string(@_); } 1; __END__