File Coverage

blib/lib/Geography/JapanesePrefectures/Unicode.pm
Criterion Covered Total %
statement 27 27 100.0
branch 2 2 100.0
condition n/a
subroutine 8 8 100.0
pod 5 5 100.0
total 42 42 100.0


line stmt bran cond sub pod time code
1             package Geography::JapanesePrefectures::Unicode;
2 2     2   10 use strict;
  2         2  
  2         57  
3 2     2   14 use warnings;
  2         3  
  2         37  
4 2     2   1843 use utf8;
  2         19  
  2         8  
5              
6             our $PREFECTURES = [
7             { id => 1, name => '北海道', region => '北海道', roman => 'Hokkaido'},
8             { id => 2, name => '青森県', region => '東北', roman => 'Aomori' },
9             { id => 3, name => '岩手県', region => '東北', roman => 'Iwate' },
10             { id => 4, name => '宮城県', region => '東北', roman => 'Miyagi' },
11             { id => 5, name => '秋田県', region => '東北', roman => 'Akita' },
12             { id => 6, name => '山形県', region => '東北', roman => 'Yamagata' },
13             { id => 7, name => '福島県', region => '東北', roman => 'Fukushima' },
14             { id => 8, name => '茨城県', region => '関東', roman => 'Ibaraki' },
15             { id => 9, name => '栃木県', region => '関東', roman => 'Tochigi' },
16             { id => 10, name => '群馬県', region => '関東', roman => 'Gunma' },
17             { id => 11, name => '埼玉県', region => '関東', roman => 'Saitama' },
18             { id => 12, name => '千葉県', region => '関東', roman => 'Chiba' },
19             { id => 13, name => '東京都', region => '関東', roman => 'Tokyo' },
20             { id => 14, name => '神奈川県', region => '関東', roman => 'Kanagawa' },
21             { id => 15, name => '新潟県', region => '信越', roman => 'Niigata' },
22             { id => 16, name => '富山県', region => '北陸', roman => 'Toyama' },
23             { id => 17, name => '石川県', region => '北陸', roman => 'Ishikawa' },
24             { id => 18, name => '福井県', region => '北陸', roman => 'Fukui' },
25             { id => 19, name => '山梨県', region => '関東', roman => 'Yamanashi' },
26             { id => 20, name => '長野県', region => '信越', roman => 'Nagano' },
27             { id => 21, name => '岐阜県', region => '東海', roman => 'Gifu' },
28             { id => 22, name => '静岡県', region => '東海', roman => 'Shizuoka' },
29             { id => 23, name => '愛知県', region => '東海', roman => 'Aichi' },
30             { id => 24, name => '三重県', region => '東海', roman => 'Mie' },
31             { id => 25, name => '滋賀県', region => '近畿', roman => 'Shiga' },
32             { id => 26, name => '京都府', region => '近畿', roman => 'Kyoto' },
33             { id => 27, name => '大阪府', region => '近畿', roman => 'Osaka' },
34             { id => 28, name => '兵庫県', region => '近畿', roman => 'Hyōgo' },
35             { id => 29, name => '奈良県', region => '近畿', roman => 'Nara' },
36             { id => 30, name => '和歌山県', region => '近畿', roman => 'Wakayama' },
37             { id => 31, name => '鳥取県', region => '中国', roman => 'Tottori' },
38             { id => 32, name => '島根県', region => '中国', roman => 'Shimane' },
39             { id => 33, name => '岡山県', region => '中国', roman => 'Okayama' },
40             { id => 34, name => '広島県', region => '中国', roman => 'Hiroshima' },
41             { id => 35, name => '山口県', region => '中国', roman => 'Yamaguchi' },
42             { id => 36, name => '徳島県', region => '四国', roman => 'Tokushima' },
43             { id => 37, name => '香川県', region => '四国', roman => 'Kagawa' },
44             { id => 38, name => '愛媛県', region => '四国', roman => 'Ehime' },
45             { id => 39, name => '高知県', region => '四国', roman => 'Kōchi' },
46             { id => 40, name => '福岡県', region => '九州', roman => 'Fukuoka' },
47             { id => 41, name => '佐賀県', region => '九州', roman => 'Saga' },
48             { id => 42, name => '長崎県', region => '九州', roman => 'Nagasaki' },
49             { id => 43, name => '熊本県', region => '九州', roman => 'Kumamoto' },
50             { id => 44, name => '大分県', region => '九州', roman => 'Ōita' },
51             { id => 45, name => '宮崎県', region => '九州', roman => 'Miyazaki' },
52             { id => 46, name => '鹿児島県', region => '九州', roman => 'Kagoshima' },
53             { id => 47, name => '沖縄県', region => '沖縄', roman => 'Okinawa' },
54             ];
55              
56             sub prefectures {
57 2     2 1 578 my $self = shift;
58 2         6 return map { $_->{name} } @$PREFECTURES;
  94         170  
59             }
60              
61             sub regions {
62 4     4 1 317 my $self = shift;
63 4         7 my %uniq;
64 4         8 return grep { !$uniq{$_}++ } map { $_->{region} } @$PREFECTURES;
  188         292  
  188         212  
65             }
66              
67             sub prefectures_in {
68 2     2 1 859 my ( $self, $region ) = @_;
69 2         5 return map { $_->{name} } grep { $_->{region} eq $region } @$PREFECTURES;
  16         32  
  94         149  
70             }
71              
72             sub prefectures_id {
73 2     2 1 44 my ( $self, $prefecture ) = @_;
74              
75 2         5 for my $pref (@$PREFECTURES) {
76 60 100       127 if ( $prefecture eq $pref->{name} ) {
77 2         11 return $pref->{id};
78             }
79             }
80             }
81              
82             sub prefectures_infos {
83 7     7 1 9 my ($self, $args) = @_;
84              
85 7         22 return $PREFECTURES;
86             }
87              
88             1;
89             __END__