tiny_eta 1.0.0 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tiny_eta.rb +4 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 02ba2f03d6d6cbf8284df9cac468855cecdcb3716a260a351f6332eac4424923
|
4
|
+
data.tar.gz: e13f8c25785550447c74e4c64fa611ebe2d606aa9850370151b8149943120a4b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1250d3341f6ee1ebdfb6abd6093fbee1ec60159bd98bcf51e522b669e315a34b101793d438340d86d1d2cb4d7e23651bae009739538e981ad8d931eaab45c20e
|
7
|
+
data.tar.gz: 4e251fe97c9c2a0690f3e101e23a48630433a87bc6648589ec5fe7f0fa8367a1c4ca6ff16008a68b1baf49657172c4555c5899a981d46a05ff5ba71140c4c164
|
data/lib/tiny_eta.rb
CHANGED
@@ -18,11 +18,14 @@ module TinyEta
|
|
18
18
|
# elapsed: the number of seconds elapsed (Integer or Float)
|
19
19
|
# percent_complete: 0.0..1.0 - the percent completion (Float)
|
20
20
|
def self.eta(elapsed, percent_complete)
|
21
|
+
return "?d ??:??:??" if percent_complete == 0
|
22
|
+
|
21
23
|
percent_remaining = (1.0 - percent_complete)
|
22
24
|
remaining_time = ((elapsed / percent_complete) * percent_remaining).round
|
23
|
-
puts remaining_time
|
24
25
|
|
25
26
|
days = (remaining_time / SECONDS_PER_DAY.to_f).to_i
|
27
|
+
return "?d ??:??:??" if days > 999
|
28
|
+
|
26
29
|
remaining_time -= days * SECONDS_PER_DAY
|
27
30
|
|
28
31
|
hours = (remaining_time / SECONDS_PER_HOUR.to_f).to_i
|