Class: ProgressBar::Components::EstimatedTimer

Inherits:
Object
  • Object
show all
Includes:
Progressable, Timer
Defined in:
lib/ruby-progressbar/components/estimated_timer.rb

Defined Under Namespace

Classes: As

Constant Summary collapse

VALID_OOB_TIME_FORMATS =
[:unknown, :friendly, nil]

Constants included from Progressable

Progressable::DEFAULT_BEGINNING_POSITION, Progressable::DEFAULT_SMOOTHING, Progressable::DEFAULT_TOTAL

Constants included from Timer

Timer::TIME_FORMAT

Instance Attribute Summary

Attributes included from Progressable

#autofinish, #finished, #progress, #running_average, #smoothing, #starting_position, #total

Instance Method Summary collapse

Methods included from Progressable

#decrement, #finish, #finished?, #increment, #percentage_completed, #percentage_completed_with_precision, #progress_made, #started?

Methods included from Timer

#pause, #resume, #started?, #stop, #stopped?

Constructor Details

#initialize(options = {}) ⇒ EstimatedTimer

Returns a new instance of EstimatedTimer.



9
10
11
12
13
14
15
# File 'lib/ruby-progressbar/components/estimated_timer.rb', line 9

def initialize(options = {})
  @out_of_bounds_time_format = nil
  @starting_at               = nil
  @stopped_at                = nil

  super
end

Instance Method Details

#out_of_bounds_time_format=(format) ⇒ Object



27
28
29
30
31
# File 'lib/ruby-progressbar/components/estimated_timer.rb', line 27

def out_of_bounds_time_format=(format)
  raise "Invalid Out Of Bounds time format.  Valid formats are #{VALID_OOB_TIME_FORMATS.inspect}" unless VALID_OOB_TIME_FORMATS.include? format

  @out_of_bounds_time_format = format
end

#resetObject



22
23
24
25
# File 'lib/ruby-progressbar/components/estimated_timer.rb', line 22

def reset
  as(Timer).reset
  as(Progressable).reset
end

#start(options = {}) ⇒ Object



17
18
19
20
# File 'lib/ruby-progressbar/components/estimated_timer.rb', line 17

def start(options = {})
  as(Timer).start
  as(Progressable).start(options)
end

#to_sObject



33
34
35
# File 'lib/ruby-progressbar/components/estimated_timer.rb', line 33

def to_s
  " ETA: #{estimated_time}"
end