Class: ProgressBar::Base
Constant Summary
collapse
- DEFAULT_OUTPUT_STREAM =
$stdout
Constants included
from Formatter
Formatter::DEFAULT_FORMAT_STRING, Formatter::DEFAULT_NON_TTY_FORMAT_STRING, Formatter::DEFAULT_TITLE
Instance Method Summary
collapse
Methods included from Formatter
#format, #progress, #total
Constructor Details
#initialize(options = {}) ⇒ Base
Returns a new instance of Base.
Instance Method Details
#clear ⇒ Object
111
112
113
114
115
116
117
118
119
120
|
# File 'lib/ruby-progressbar/base.rb', line 111
def clear
self.last_update_length = 0
if output.tty?
output.print clear_string
output.print "\r"
else
output.print "\n"
end
end
|
#decrement ⇒ Object
Updating The Bar’s Progress
37
38
39
|
# File 'lib/ruby-progressbar/base.rb', line 37
def decrement
update_progress(:decrement)
end
|
#finish ⇒ Object
56
57
58
|
# File 'lib/ruby-progressbar/base.rb', line 56
def finish
with_update { with_progressables(:finish); with_timers(:stop) } unless finished?
end
|
#finished? ⇒ Boolean
85
86
87
|
# File 'lib/ruby-progressbar/base.rb', line 85
def finished?
@estimated_time.finished? && @bar.finished?
end
|
#increment ⇒ Object
41
42
43
|
# File 'lib/ruby-progressbar/base.rb', line 41
def increment
update_progress(:increment)
end
|
#inspect ⇒ Object
139
140
141
|
# File 'lib/ruby-progressbar/base.rb', line 139
def inspect
"#<ProgressBar:#{progress}/#{total || 'unknown'}>"
end
|
#log(string) ⇒ Object
126
127
128
129
130
131
|
# File 'lib/ruby-progressbar/base.rb', line 126
def log(string)
clear
output.puts string
update(:force => true) unless stopped?
end
|
#pause ⇒ Object
60
61
62
|
# File 'lib/ruby-progressbar/base.rb', line 60
def pause
with_update { with_timers(:pause) } unless paused?
end
|
#progress=(new_progress) ⇒ Object
45
46
47
|
# File 'lib/ruby-progressbar/base.rb', line 45
def progress=(new_progress)
update_progress(:progress=, new_progress)
end
|
#progress_mark=(mark) ⇒ Object
96
97
98
|
# File 'lib/ruby-progressbar/base.rb', line 96
def progress_mark=(mark)
with_update { @bar.progress_mark = mark }
end
|
#refresh ⇒ Object
122
123
124
|
# File 'lib/ruby-progressbar/base.rb', line 122
def refresh
update
end
|
#remainder_mark=(mark) ⇒ Object
100
101
102
|
# File 'lib/ruby-progressbar/base.rb', line 100
def remainder_mark=(mark)
with_update { @bar.remainder_mark = mark }
end
|
#reset ⇒ Object
72
73
74
75
76
77
|
# File 'lib/ruby-progressbar/base.rb', line 72
def reset
with_update do
@bar.reset
with_timers(:reset)
end
end
|
#resume ⇒ Object
68
69
70
|
# File 'lib/ruby-progressbar/base.rb', line 68
def resume
with_update { with_timers(:resume) } if stopped?
end
|
#start(options = {}) ⇒ Object
25
26
27
28
29
30
31
32
|
# File 'lib/ruby-progressbar/base.rb', line 25
def start(options = {})
clear
with_update do
with_progressables(:start, options)
with_timers(:start)
end
end
|
#started? ⇒ Boolean
89
90
91
|
# File 'lib/ruby-progressbar/base.rb', line 89
def started?
@estimated_time.started? && @elapsed_time.started? && @bar.started?
end
|
#stop ⇒ Object
64
65
66
|
# File 'lib/ruby-progressbar/base.rb', line 64
def stop
with_update { with_timers(:stop) } unless stopped?
end
|
#stopped? ⇒ Boolean
Also known as:
paused?
79
80
81
|
# File 'lib/ruby-progressbar/base.rb', line 79
def stopped?
(@estimated_time.stopped? && @elapsed_time.stopped?) || finished?
end
|
#title=(title) ⇒ Object
104
105
106
|
# File 'lib/ruby-progressbar/base.rb', line 104
def title=(title)
with_update { super }
end
|
#to_s(format_string = nil) ⇒ Object
133
134
135
136
137
|
# File 'lib/ruby-progressbar/base.rb', line 133
def to_s(format_string = nil)
format_string ||= @format_string
format(format_string)
end
|
#total=(new_total) ⇒ Object
49
50
51
|
# File 'lib/ruby-progressbar/base.rb', line 49
def total=(new_total)
update_progress(:total=, new_total)
end
|