Class: Eta::Estimator

Inherits:
Object
  • Object
show all
Defined in:
lib/eta/estimator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#percent_doneObject

Returns the value of attribute percent_done.



3
4
5
# File 'lib/eta/estimator.rb', line 3

def percent_done
  @percent_done
end

Instance Method Details

#current_timeObject



25
26
27
# File 'lib/eta/estimator.rb', line 25

def current_time
  Time.now.to_i
end

#elapsed_timeObject



21
22
23
# File 'lib/eta/estimator.rb', line 21

def elapsed_time
  current_time - @start_time
end

#etaObject



9
10
11
# File 'lib/eta/estimator.rb', line 9

def eta
  Time.at(current_time.to_i + time_left)
end

#expected_durationObject



17
18
19
# File 'lib/eta/estimator.rb', line 17

def expected_duration
  elapsed_time / percent_done
end

#start!Object



5
6
7
# File 'lib/eta/estimator.rb', line 5

def start!
  @start_time = current_time
end

#time_leftObject



13
14
15
# File 'lib/eta/estimator.rb', line 13

def time_left
  expected_duration - elapsed_time
end