tiny_eta 1.0.0 → 1.0.1

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 -0
  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: df7971d0e4357130ab623fdf5f7c913519f08a8e6279f6dbd8dc347599257bea
4
+ data.tar.gz: 6377a1c565dd139be96049a468db611e60d3f8eb4b7b6118c6abe48b4936e5c5
5
5
  SHA512:
6
- metadata.gz: 1f7c9ee316300a4618a92133ab728c1266d5a39f06f06bdb880eb905ad4cbec30ac3596d868ac96c019305801758989a992b985f3737015a28b562d7991ca21f
7
- data.tar.gz: 923a8cd621bad25c85517c729b84f3bcbeb6272d7970a6b31af20e143c4fdcac812034411fb434e214cef85a87422390193d19cd5ac70cd20c713fdc2d254f99
6
+ metadata.gz: 694f1021815f0ed255a04c45792635373aad552a617b9c95b7c3250cdc7bc38c80cbb40fe22922e6c35e7177d46a081590f95aaead5efef02ab0b52b0ade436c
7
+ data.tar.gz: add57c787cf01b2dd745a5452ded44c392688a7639c41613f5e15abee2b73af426c3edda29b376ceb905bbc06fa3fbc9386e39ab901375851e31ab8ff979dc12
data/lib/tiny_eta.rb CHANGED
@@ -18,11 +18,15 @@ 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
25
  puts remaining_time
24
26
 
25
27
  days = (remaining_time / SECONDS_PER_DAY.to_f).to_i
28
+ return "?d ??:??:??" if days > 999
29
+
26
30
  remaining_time -= days * SECONDS_PER_DAY
27
31
 
28
32
  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.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Lunt