wxl_process_bar 1.0.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.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/wxl_process_bar.rb +48 -0
  3. metadata +44 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: b744bb943921ff7dc94922e6545516b8cf22a4a340bd2615b8bd28d94d549615
4
+ data.tar.gz: 2c37a466555ce6f03a46aa090e7db807ba9314b94bc72159a17320507eaeecbb
5
+ SHA512:
6
+ metadata.gz: c7829b8c8b37856360c34e5204bd8ee34c58a97bfc8650072f7148f97ecc3d8e27a9920b342fe608d3ff76153a979cd03a97709dc9bc9ce933b69dfd30a5c591
7
+ data.tar.gz: 2beb84114c67aa12e81db52cf77b99edd882937f79141ece5b0847d5a497a4c2b71abd5e8f78d9815aedd126a8e6a4d9b80f5906ec84fb6efd19b501fecc9be1
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env ruby
2
+ # coding: utf-8
3
+
4
+ require "io/console"
5
+ 获取窗口高_按字符=STDOUT.winsize[0]
6
+ 获取窗口宽_按行数=STDOUT.winsize[1]
7
+
8
+ class C_进度条
9
+ #
10
+ # 最后的减2,是因为京都条的收尾,各有一个|,计算的宽度的时候,必须去掉
11
+ # 默认宽度,就是屏幕宽度
12
+ def initialize(循环次数,宽度=STDOUT.winsize[1]-2)
13
+ @当前循环次数=1
14
+ @循环次数=循环次数
15
+ @显示宽度=宽度
16
+ end
17
+
18
+ def 更新
19
+ 当前比例=((@当前循环次数.to_f/@循环次数)*@显示宽度).to_i
20
+ 剩余比例=@显示宽度-当前比例
21
+ print "|";
22
+ 当前比例.times { print "#"};
23
+ 剩余比例.times {print " "};
24
+ print "|";
25
+ if 剩余比例 == 0
26
+ print "\n"
27
+ else
28
+ print "\r" #光标到行首
29
+ $stdout.flush
30
+ end
31
+ @当前循环次数 += 1
32
+ end
33
+
34
+ def 更新记录到日志
35
+ 当前比例=((@当前循环次数.to_f/@循环次数)*50).to_i
36
+ 剩余比例=50-当前比例
37
+ 行=''
38
+ 行 << "|";
39
+ 当前比例.times { 行 << "#"};
40
+ 剩余比例.times { 行 << " "};
41
+ 行 << "|";
42
+ 行 << "\n"
43
+ @当前循环次数 += 1
44
+ return 行
45
+ end
46
+ end
47
+
48
+
metadata ADDED
@@ -0,0 +1,44 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: wxl_process_bar
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - wxl
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-12-06 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: a process bar made by wxl
14
+ email: wangxl_bj2008@foxmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - "./lib/wxl_process_bar.rb"
20
+ homepage: https://github.com/lebashupian/wxl_process_bar
21
+ licenses:
22
+ - MIT
23
+ metadata: {}
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 2.2.0
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ requirements: []
39
+ rubyforge_project:
40
+ rubygems_version: 2.7.6
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: a process bar
44
+ test_files: []