| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
10
|
|
|
10
|
|
9244
|
use v5.40; |
|
|
10
|
|
|
|
|
37
|
|
|
2
|
10
|
|
|
10
|
|
67
|
use feature 'class'; |
|
|
10
|
|
|
|
|
21
|
|
|
|
10
|
|
|
|
|
1265
|
|
|
3
|
10
|
|
|
10
|
|
49
|
no warnings 'experimental::class'; |
|
|
10
|
|
|
|
|
17
|
|
|
|
10
|
|
|
|
|
895
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
class App::Gimei::Generator { |
|
6
|
|
|
|
|
|
|
|
|
7
|
10
|
|
|
10
|
|
4907
|
use Data::Gimei; |
|
|
10
|
|
|
|
|
506669
|
|
|
|
10
|
|
|
|
|
5921
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# |
|
10
|
|
|
|
|
|
|
# instance variables |
|
11
|
|
|
|
|
|
|
# |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
field $word_class : param : reader; # Name or Address |
|
14
|
|
|
|
|
|
|
field $word_subtype : param : reader = undef; # 'gender', 'surname', 'forename', |
|
15
|
|
|
|
|
|
|
# 'prefecture', 'city', 'town' or undef |
|
16
|
|
|
|
|
|
|
field $rendering : param : reader = |
|
17
|
|
|
|
|
|
|
'kanji'; # 'kanji', 'hiragana', 'katakana' or 'romaji' |
|
18
|
|
|
|
|
|
|
field $gender : param : reader = undef; # 'name', 'male', 'female' or undef |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# |
|
21
|
|
|
|
|
|
|
# instance methods |
|
22
|
|
|
|
|
|
|
# |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# Returns generated string if cache missed |
|
25
|
|
|
|
|
|
|
method execute ($cache) { |
|
26
|
|
|
|
|
|
|
my ($word); |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# Fetch from cache |
|
29
|
|
|
|
|
|
|
my $key = $word_class . ( $gender // '' ); # cache key |
|
30
|
|
|
|
|
|
|
$word = $cache->{$key}; |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# Generate if chache missed |
|
33
|
|
|
|
|
|
|
if ( !defined $word ) { |
|
34
|
|
|
|
|
|
|
$word = $word_class->new( gender => $gender ); |
|
35
|
|
|
|
|
|
|
$cache->{$key} = $word; # cache it |
|
36
|
|
|
|
|
|
|
} |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# Extract subtype |
|
39
|
|
|
|
|
|
|
if ($word_subtype) { |
|
40
|
|
|
|
|
|
|
if ( $word_subtype eq 'gender' ) { |
|
41
|
|
|
|
|
|
|
return $word->gender; |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
my $call = $word->can($word_subtype); |
|
44
|
|
|
|
|
|
|
$word = $word->$call(); |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# Apply rendering |
|
48
|
|
|
|
|
|
|
my $call = $word->can($rendering); |
|
49
|
|
|
|
|
|
|
$word = $word->$call(); |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
return $word; |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
1; |