shuang_pin_tutorial 1.2.2 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/shuang_pin_tutorial.rb +1 -1
- data/lib/shuang_pin_tutorial/handler.rb +37 -13
- data/lib/shuang_pin_tutorial/main.rb +2 -4
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa6cc5fb89f01c29c889dd3b703005856f1f8e664c3516e18fa763a95193e49c
|
4
|
+
data.tar.gz: c7c440bda2c4e47a1e562b316e340e8600294ec8eff011ddcef51d1563c9ed3a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a299446b467c6cb1b519b42cf9e17a21c98467dc6a22ee7f49822a8700a89fca2c04722a1ffbd48a4d68ec8c0032e43b16cef49b80e354dec7d5b2c7f352845
|
7
|
+
data.tar.gz: ee017c5cea1efc50e60aab72ce2719633d2004bf16001bf8fe2b9a38709517d74eaa51c85b11ee2c049565f82bf2e234b11db396ddd4ff2cda1ca4243c2adc7b
|
data/lib/shuang_pin_tutorial.rb
CHANGED
@@ -14,7 +14,7 @@ end
|
|
14
14
|
module ShuangPinTutorial
|
15
15
|
MODULE = "ShuangPinTutorial"
|
16
16
|
NAME = "shuang_pin_tutorial"
|
17
|
-
VERSION = "1.
|
17
|
+
VERSION = "1.3.0"
|
18
18
|
OPTIONS = {w: "words", r: "remind_off", z: "zhuyin_off", c: "cword_off"}
|
19
19
|
OPTIONS_DEFAULT = {w: 6, r: true, z: true, c: true}
|
20
20
|
|
@@ -20,10 +20,10 @@ module ShuangPinTutorial
|
|
20
20
|
# 初始化
|
21
21
|
@sp_data = Data.new()
|
22
22
|
@words_counts = [0, 0, 0]
|
23
|
-
@start_time = DateTime.now
|
24
|
-
@
|
23
|
+
@start_time, @end_time = DateTime.now, nil # Datetime
|
24
|
+
@total_time, @type_speed = nil, nil # Rational
|
25
25
|
puts "歡迎使用 快速學習雙拼 -- 微軟雙拼(繁體中文版)!要好好練習哦!(#{VERSION} 版)"
|
26
|
-
puts "要輸入下面中文字對應雙拼字碼哦!使用空格隔開,要休息請輸入 'exit' 或按
|
26
|
+
puts "要輸入下面中文字對應雙拼字碼哦!使用空格隔開,要休息請輸入 'exit' 或按 ctrl+c 吧!\n"
|
27
27
|
# looping
|
28
28
|
while true
|
29
29
|
result = get_question_lines
|
@@ -40,6 +40,11 @@ module ShuangPinTutorial
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
+
def stop()
|
44
|
+
@end_time = DateTime.now
|
45
|
+
@total_time = (@end_time - @start_time) * 24 * 60 * 60
|
46
|
+
end
|
47
|
+
|
43
48
|
def get_words_showlines(num = @int_words_displayed, display_delim: "|") # return [words(str), [display line(s)]]
|
44
49
|
result = []
|
45
50
|
display = []
|
@@ -109,12 +114,22 @@ module ShuangPinTutorial
|
|
109
114
|
result
|
110
115
|
end
|
111
116
|
|
117
|
+
def print_results
|
118
|
+
total_time = get_total_time_str
|
119
|
+
$stdout.puts("#{total_time}") if (total_time)
|
120
|
+
total_words_result = get_total_words_result
|
121
|
+
$stdout.puts("#{total_words_result}") if (total_words_result)
|
122
|
+
percent_correctness = get_percent_correctness
|
123
|
+
$stdout.puts("#{percent_correctness}") if (percent_correctness)
|
124
|
+
type_speed = get_type_speed_str
|
125
|
+
$stdout.puts("#{type_speed}") if (type_speed)
|
126
|
+
end
|
127
|
+
|
112
128
|
def get_total_time_str
|
113
|
-
@
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
str_total_time_h = Time.at(@total_time).utc.strftime("%H").gsub(/^0+/, '')
|
129
|
+
return nil unless @words_counts[0] > 0
|
130
|
+
str_total_time_s = Time.at(@total_time.to_i).utc.strftime("%S").gsub(/^0/, '')
|
131
|
+
str_total_time_m = Time.at(@total_time.to_i).utc.strftime("%M").gsub(/^0/, '')
|
132
|
+
str_total_time_h = Time.at(@total_time.to_i).utc.strftime("%H").gsub(/^0+/, '')
|
118
133
|
str_total_time =
|
119
134
|
case @total_time
|
120
135
|
when 0...60
|
@@ -124,15 +139,24 @@ module ShuangPinTutorial
|
|
124
139
|
else
|
125
140
|
"#{str_total_time_h} 小時 #{str_total_time_m} 分 #{str_total_time_s} 秒"
|
126
141
|
end
|
127
|
-
str_total_time
|
142
|
+
"訓練時間: #{str_total_time}"
|
128
143
|
end
|
129
144
|
|
130
145
|
def get_total_words_result
|
146
|
+
return nil unless @words_counts[0] > 0
|
147
|
+
"共有字數: #{@words_counts[0]} 字(#{@words_counts[1]}-#{@words_counts[2]})"
|
148
|
+
end
|
149
|
+
|
150
|
+
def get_percent_correctness
|
151
|
+
return nil unless @words_counts[0] > 0
|
131
152
|
percent_correctness = @words_counts[0].to_f != 0 ? (@words_counts[1].to_f/@words_counts[0].to_f) * 100 : 0
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
153
|
+
"總正確率: #{percent_correctness.round(2)} %"
|
154
|
+
end
|
155
|
+
|
156
|
+
def get_type_speed_str
|
157
|
+
return nil unless @words_counts[0] > 0 && @words_counts[1] > 0
|
158
|
+
@type_speed = @total_time / @words_counts[1] # 只計算正確字數
|
159
|
+
"平均速度: #{@type_speed.to_f.floor(2)} 秒/字"
|
136
160
|
end
|
137
161
|
end
|
138
162
|
end
|
@@ -20,11 +20,9 @@ module ShuangPinTutorial
|
|
20
20
|
# $stderr.puts(ex.backtrace) # debug use only
|
21
21
|
@is_run_success = false
|
22
22
|
ensure
|
23
|
+
@obj_tutorial.stop()
|
23
24
|
exit(@is_run_success) unless @is_run_success
|
24
|
-
|
25
|
-
$stdout.puts(@obj_tutorial.get_total_time_str)
|
26
|
-
$stdout.puts('成果統計:')
|
27
|
-
$stdout.puts(@obj_tutorial.get_total_words_result)
|
25
|
+
@obj_tutorial.print_results
|
28
26
|
$stdout.puts('要努力學習哦,感謝使用!')
|
29
27
|
exit(@is_run_success)
|
30
28
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shuang_pin_tutorial
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David N
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-03-
|
11
|
+
date: 2020-03-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mercenary
|
@@ -41,7 +41,7 @@ files:
|
|
41
41
|
- lib/shuang_pin_tutorial/data.rb
|
42
42
|
- lib/shuang_pin_tutorial/handler.rb
|
43
43
|
- lib/shuang_pin_tutorial/main.rb
|
44
|
-
homepage:
|
44
|
+
homepage: http://jsdn.hk/shuang_pin_tutorial/
|
45
45
|
licenses:
|
46
46
|
- MIT
|
47
47
|
metadata:
|