console_progress 0.1.3 → 0.1.4
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/README.md +2 -2
- data/lib/console_progress.rb +8 -3
- data/lib/console_progress/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 699eab3bd36420e6ad9c64d93ae03a8903e141c8
|
4
|
+
data.tar.gz: 061d92aeec24fa5fdf20595c54d6b39bbee9a270
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2215ee11ec8559c1cf0e0ab38071a40e7ed2c054b70ae536172b09588c9046662ed6bdc6e3ea5ddf9d13c5612a1b2d6b0ba501c83ab0783b4c6b943aa06239a6
|
7
|
+
data.tar.gz: e4ffc1bc19d3f48c7ff78816102a32d914ea5a095a426cd372bee7ae01a9a4933cdae2b1a6c8572b8bb1f5724c9039edfb8b22ad5f9fa31b708311861a23c4dc
|
data/README.md
CHANGED
@@ -42,8 +42,8 @@ You can also do it every 10 steps by doing something like this:
|
|
42
42
|
```
|
43
43
|
prog = ConsoleProgress::ETA.new(100)
|
44
44
|
prog.start
|
45
|
-
100.times do
|
46
|
-
|
45
|
+
100.times do
|
46
|
+
eta.put_if(10)
|
47
47
|
sleep 2
|
48
48
|
end
|
49
49
|
```
|
data/lib/console_progress.rb
CHANGED
@@ -58,12 +58,17 @@ module ConsoleProgress
|
|
58
58
|
out
|
59
59
|
end
|
60
60
|
|
61
|
+
def put_if(limit)
|
62
|
+
out = progress
|
63
|
+
puts out if @step % limit == 0
|
64
|
+
end
|
65
|
+
|
61
66
|
def seconds_to_time(t)
|
62
67
|
mm, ss = t.divmod(60)
|
63
68
|
hh, mm = mm.divmod(60)
|
64
69
|
dd, hh = hh.divmod(24)
|
65
70
|
[dd, hh, mm, ss].delete_if {|r| r == 0}
|
66
|
-
.map
|
71
|
+
.map {|r| '%02d' % r.to_i}
|
67
72
|
.join(':')
|
68
73
|
end
|
69
74
|
|
@@ -79,8 +84,8 @@ module ConsoleProgress
|
|
79
84
|
def self.example2
|
80
85
|
eta = ConsoleProgress::ETA.new(100)
|
81
86
|
eta.start
|
82
|
-
100.times do
|
83
|
-
|
87
|
+
100.times do
|
88
|
+
eta.put_if(10)
|
84
89
|
sleep 1
|
85
90
|
end
|
86
91
|
end
|