Class: ProgressBar::Components::EstimatedTimer

Inherits:
Object
  • Object
show all
Includes:
Progressable, Timer
Defined in:
lib/progress_bar/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

#progress, #running_average, #smoothing, #starting_position, #total

Instance Method Summary collapse

Methods included from Progressable

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

Methods included from Timer

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

Constructor Details

#initialize(options = {}) ⇒ EstimatedTimer

Returns a new instance of EstimatedTimer.



9
10
11
# File 'lib/progress_bar/components/estimated_timer.rb', line 9

def initialize(options = {})
  super
end

Instance Method Details

#out_of_bounds_time_format=(format) ⇒ Object



23
24
25
26
27
# File 'lib/progress_bar/components/estimated_timer.rb', line 23

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



18
19
20
21
# File 'lib/progress_bar/components/estimated_timer.rb', line 18

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

#start(options = {}) ⇒ Object



13
14
15
16
# File 'lib/progress_bar/components/estimated_timer.rb', line 13

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

#to_sObject



29
30
31
# File 'lib/progress_bar/components/estimated_timer.rb', line 29

def to_s
  " ETA: #{estimated_time}"
end