mirror of
https://github.com/RubyMetric/chsrc
synced 2025-07-21 23:59:33 +08:00
Give Unknown if codeblock not specify
This commit is contained in:
parent
2a27fd4fc1
commit
8259a5fd9a
@ -94,10 +94,23 @@ class SectionConfig {
|
||||
return self.get-inherited-config('keep-postfix', 'true');
|
||||
}
|
||||
|
||||
#| RS4C-String 或 RS4C-Nil
|
||||
|
||||
#| RS4C-String
|
||||
method language() {
|
||||
return self.get-direct-config('language');
|
||||
# RS4C-String 或 RS4C-Nil
|
||||
my $config-language = self.get-direct-config('language');
|
||||
|
||||
my Str $lang;
|
||||
|
||||
if $config-language.is-nil {
|
||||
# codeblock 没有写语言,就给 Unknown
|
||||
$lang = 'Unknown';
|
||||
} else {
|
||||
$lang = $config-language.string-value;
|
||||
}
|
||||
return Parser::ConfigItem's-Value.new($lang);
|
||||
}
|
||||
|
||||
|
||||
#| RS4C-String
|
||||
method name() {
|
||||
|
@ -70,22 +70,22 @@ class ConfigItem's-Value {
|
||||
# 这些函数防止开发者写错类型
|
||||
method nil-value() {
|
||||
return self.value if $.type == RS4C-Nil;
|
||||
die "The config value type is not RS4C-Nil, but: {$.type}";
|
||||
die "The config value type should be RS4C-Nil, but it is: {$.type}";
|
||||
}
|
||||
|
||||
method string-value() {
|
||||
return self.value if $.type == RS4C-String;
|
||||
die "The config value type is not RS4C-String, but: {$.type}";
|
||||
die "The config value type should be RS4C-String, but it is: {$.type}";
|
||||
}
|
||||
|
||||
method bool-value() {
|
||||
return self.value if $.type == RS4C-Bool;
|
||||
die "The config value type is not RS4C-Bool, but: {$.type}";
|
||||
die "The config value type should be RS4C-Bool, but it is: {$.type}";
|
||||
}
|
||||
|
||||
method mode-value() {
|
||||
return self.value if $.type == RS4C-Mode;
|
||||
die "The config value type is not RS4C-Mode, but: {$.type}";
|
||||
die "The config value type should be RS4C-Mode, but it is: {$.type}";
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user