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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/tiny_eta.rb +4 -1
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a67e335df4b6df5f98705c220ab51a214af310bffde49feb6685228852c96c80
4
- data.tar.gz: 9f05a43486bed958b949ef23cd35358c02fe7a1a29b12a652deed7c4e9ff505b
3
+ metadata.gz: 02ba2f03d6d6cbf8284df9cac468855cecdcb3716a260a351f6332eac4424923
4
+ data.tar.gz: e13f8c25785550447c74e4c64fa611ebe2d606aa9850370151b8149943120a4b
5
5
  SHA512:
6
- metadata.gz: 1f7c9ee316300a4618a92133ab728c1266d5a39f06f06bdb880eb905ad4cbec30ac3596d868ac96c019305801758989a992b985f3737015a28b562d7991ca21f
7
- data.tar.gz: 923a8cd621bad25c85517c729b84f3bcbeb6272d7970a6b31af20e143c4fdcac812034411fb434e214cef85a87422390193d19cd5ac70cd20c713fdc2d254f99
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tiny_eta
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Lunt