wxl_process_bar 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/wxl_process_bar.rb +13 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cfb1da2d234c988bb7b964cd843146d36453d4b7c34f0c38e3063db69b1526e0
|
4
|
+
data.tar.gz: 9c6e0a03f977695078d57ca19c77d08fd7e7171fd5b77ff2d5143163f094a48e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7fee09ba817a54936d37c99649506a286a5ebe212531428257ef80efe563c85884498a08969f013f0660f09fdbf285c46d1a754193cba8d617c6573b62238e49
|
7
|
+
data.tar.gz: 1620ea70145ca9fb58e6cce5300f696439201d7f5dced3d53e8e8abeeee400a09a4f132702a3d29ac2281da20cdfbcbff3bf744c8f8209fbe74b2ec86932721e
|
data/lib/wxl_process_bar.rb
CHANGED
@@ -9,19 +9,24 @@ class C_进度条
|
|
9
9
|
#
|
10
10
|
# 最后的减2,是因为京都条的收尾,各有一个|,计算的宽度的时候,必须去掉
|
11
11
|
# 默认宽度,就是屏幕宽度
|
12
|
-
def initialize(循环次数,宽度=STDOUT.winsize[1]-2)
|
12
|
+
def initialize(循环次数,宽度=STDOUT.winsize[1]-2-循环次数.size)
|
13
|
+
p 宽度
|
13
14
|
@当前循环次数=1
|
14
15
|
@循环次数=循环次数
|
15
16
|
@显示宽度=宽度
|
17
|
+
@开始时间=Time.new
|
18
|
+
@当前时间=nil
|
16
19
|
end
|
17
20
|
|
18
21
|
def 更新
|
22
|
+
@当前时间=Time.new
|
19
23
|
当前比例=((@当前循环次数.to_f/@循环次数)*@显示宽度).to_i
|
20
24
|
剩余比例=@显示宽度-当前比例
|
21
25
|
print "|";
|
22
26
|
当前比例.times { print "#"};
|
23
27
|
剩余比例.times {print " "};
|
24
28
|
print "|";
|
29
|
+
print "#{@当前循环次数}/#{@循环次数} times:#{(@当前时间-@开始时间).floor(3)}s"
|
25
30
|
if 剩余比例 == 0
|
26
31
|
print "\n"
|
27
32
|
else
|
@@ -44,5 +49,10 @@ class C_进度条
|
|
44
49
|
return 行
|
45
50
|
end
|
46
51
|
end
|
47
|
-
|
48
|
-
|
52
|
+
循环次数=10
|
53
|
+
显示宽度=50
|
54
|
+
进度条=C_进度条.new 循环次数,显示宽度
|
55
|
+
循环次数.times {
|
56
|
+
进度条.更新
|
57
|
+
sleep 0.5
|
58
|
+
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wxl_process_bar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- wxl
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-02-16 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: a process bar made by wxl
|
14
14
|
email: wangxl_bj2008@foxmail.com
|