Class: Eta::Estimator
- Inherits:
-
Object
- Object
- Eta::Estimator
- Defined in:
- lib/eta/estimator.rb
Instance Attribute Summary collapse
-
#percent_done ⇒ Object
Returns the value of attribute percent_done.
Instance Method Summary collapse
- #current_time ⇒ Object
- #elapsed_time ⇒ Object
- #eta ⇒ Object
- #expected_duration ⇒ Object
- #start! ⇒ Object
- #time_left ⇒ Object
Instance Attribute Details
#percent_done ⇒ Object
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_time ⇒ Object
25 26 27 |
# File 'lib/eta/estimator.rb', line 25 def current_time Time.now.to_i end |
#elapsed_time ⇒ Object
21 22 23 |
# File 'lib/eta/estimator.rb', line 21 def elapsed_time current_time - @start_time end |
#eta ⇒ Object
9 10 11 |
# File 'lib/eta/estimator.rb', line 9 def eta Time.at(current_time.to_i + time_left) end |
#expected_duration ⇒ Object
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_left ⇒ Object
13 14 15 |
# File 'lib/eta/estimator.rb', line 13 def time_left expected_duration - elapsed_time end |