Class: ProgressBar::Base
Constant Summary
collapse
- DEFAULT_OUTPUT_STREAM =
STDOUT
Constants included
from Depreciable
Depreciable::DEPRECATION_DATE
Constants included
from Formatter
Formatter::DEFAULT_FORMAT_STRING, Formatter::DEFAULT_TITLE
Instance Method Summary
collapse
#backwards_compatible_args_to_options_conversion, #bar_mark=, #current, #file_transfer_mode, #format=, #format_arguments=, #halt, #inc, #set, #smoothing, #smoothing=, #start_time, #start_time=, #title_width, #title_width=
Methods included from Formatter
#format, #progress, #total
Constructor Details
#initialize(*args) ⇒ Base
Returns a new instance of Base.
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/progress_bar/base.rb', line 9
def initialize(*args)
options = args.empty? ? {} : backwards_compatible_args_to_options_conversion(args)
self.output = options[:output] || DEFAULT_OUTPUT_STREAM
super(options)
@bar = Components::Bar.new(options)
@estimated_time = Components::EstimatedTimer.new(options)
@elapsed_time = Components::ElapsedTimer.new
start :at => options[:starting_at]
end
|
Instance Method Details
#clear ⇒ Object
100
101
102
|
# File 'lib/progress_bar/base.rb', line 100
def clear
output.print clear_string
end
|
#decrement ⇒ Object
Updating The Bar’s Progress
38
39
40
|
# File 'lib/progress_bar/base.rb', line 38
def decrement
with_update { with_progressables(:decrement) }
end
|
#finish ⇒ Object
53
54
55
|
# File 'lib/progress_bar/base.rb', line 53
def finish
with_update { with_progressables(:finish) }
end
|
#finished? ⇒ Boolean
82
83
84
|
# File 'lib/progress_bar/base.rb', line 82
def finished?
@bar.progress == @bar.total
end
|
#increment ⇒ Object
42
43
44
|
# File 'lib/progress_bar/base.rb', line 42
def increment
with_update { with_progressables(:increment) }
end
|
#inspect ⇒ Object
114
115
116
|
# File 'lib/progress_bar/base.rb', line 114
def inspect
"#<ProgressBar:#{progress}/#{total}>"
end
|
#pause ⇒ Object
57
58
59
|
# File 'lib/progress_bar/base.rb', line 57
def pause
with_update { with_timers(:pause) }
end
|
#progress=(new_progress) ⇒ Object
46
47
48
|
# File 'lib/progress_bar/base.rb', line 46
def progress=(new_progress)
with_update { with_progressables(:progress=, new_progress) }
end
|
#progress_mark=(mark) ⇒ Object
89
90
91
|
# File 'lib/progress_bar/base.rb', line 89
def progress_mark=(mark)
with_update { @bar.progress_mark = mark }
end
|
#refresh ⇒ Object
104
105
106
|
# File 'lib/progress_bar/base.rb', line 104
def refresh
update
end
|
#reset ⇒ Object
69
70
71
72
73
74
|
# File 'lib/progress_bar/base.rb', line 69
def reset
with_update do
@bar.reset
with_timers(:reset)
end
end
|
#resume ⇒ Object
65
66
67
|
# File 'lib/progress_bar/base.rb', line 65
def resume
with_update { with_timers(:resume) }
end
|
#start(options = {}) ⇒ Object
26
27
28
29
30
31
32
33
|
# File 'lib/progress_bar/base.rb', line 26
def start(options = {})
clear
with_update do
with_progressables(:start, options)
@elapsed_time.start
end
end
|
#stop ⇒ Object
61
62
63
|
# File 'lib/progress_bar/base.rb', line 61
def stop
with_update { with_timers(:stop) }
end
|
#stopped? ⇒ Boolean
Also known as:
paused?
76
77
78
|
# File 'lib/progress_bar/base.rb', line 76
def stopped?
@estimated_time.stopped? && @elapsed_time.stopped?
end
|
#title=(title) ⇒ Object
93
94
95
|
# File 'lib/progress_bar/base.rb', line 93
def title=(title)
with_update { super }
end
|
#to_s(format_string = nil) ⇒ Object
108
109
110
111
112
|
# File 'lib/progress_bar/base.rb', line 108
def to_s(format_string = nil)
format_string ||= @format_string
format(format_string)
end
|