Class: Rex::Ui::ProgressTracker
- Inherits:
-
Object
- Object
- Rex::Ui::ProgressTracker
- Defined in:
- lib/rex/ui/progress_tracker.rb
Overview
This module tracks the progress of an arbitrary task in a generic fashion. The actual implementation is left up to the thing that derives from this module.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#pos ⇒ Object
The current position in the progress.
-
#start ⇒ Object
The start of the progress.
-
#stop ⇒ Object
The last position in the progress.
Instance Method Summary collapse
-
#abort(msg = nil) ⇒ Object
Progress has been aborted, the reason is supplied in msg.
-
#error(msg = nil) ⇒ Object
An error occurred that may result in aborting the progress.
-
#initialize ⇒ ProgressTracker
constructor
A new instance of ProgressTracker.
-
#range=(rng) ⇒ Object
Sets start and step using a range.
-
#reset(n = self.start) ⇒ Object
Resets the current step location.
-
#status(msg = nil) ⇒ Object
Passes a generic status message that isn’t necessarily associated with a step event.
-
#step(status = nil, n = 1) ⇒ Object
Steps with a given message and step size.
-
#step_status(msg = nil) ⇒ Object
Updates the status associated with the current step.
Constructor Details
#initialize ⇒ ProgressTracker
Returns a new instance of ProgressTracker.
16 17 18 19 20 |
# File 'lib/rex/ui/progress_tracker.rb', line 16 def initialize self.start = 0 self.stop = 0 self.pos = 0 end |
Instance Attribute Details
#pos ⇒ Object
The current position in the progress.
92 93 94 |
# File 'lib/rex/ui/progress_tracker.rb', line 92 def pos @pos end |
#start ⇒ Object
The start of the progress.
84 85 86 |
# File 'lib/rex/ui/progress_tracker.rb', line 84 def start @start end |
#stop ⇒ Object
The last position in the progress.
88 89 90 |
# File 'lib/rex/ui/progress_tracker.rb', line 88 def stop @stop end |
Instance Method Details
#abort(msg = nil) ⇒ Object
Progress has been aborted, the reason is supplied in msg.
78 79 |
# File 'lib/rex/ui/progress_tracker.rb', line 78 def abort(msg = nil) end |
#error(msg = nil) ⇒ Object
An error occurred that may result in aborting the progress.
72 73 |
# File 'lib/rex/ui/progress_tracker.rb', line 72 def error(msg = nil) end |
#range=(rng) ⇒ Object
Sets start and step using a range.
25 26 27 28 |
# File 'lib/rex/ui/progress_tracker.rb', line 25 def range=(rng) self.start = rng.begin self.stop = rng.end end |
#reset(n = self.start) ⇒ Object
Resets the current step location.
52 53 54 |
# File 'lib/rex/ui/progress_tracker.rb', line 52 def reset(n = self.start) self.pos = n end |
#status(msg = nil) ⇒ Object
Passes a generic status message that isn’t necessarily associated with a step event.
60 61 |
# File 'lib/rex/ui/progress_tracker.rb', line 60 def status(msg = nil) end |
#step(status = nil, n = 1) ⇒ Object
Steps with a given message and step size.
41 42 43 44 45 46 47 |
# File 'lib/rex/ui/progress_tracker.rb', line 41 def step(status = nil, n = 1) self.pos += n if (self.pos + n <= self.stop) step_status(status) self.pos end |
#step_status(msg = nil) ⇒ Object
Updates the status associated with the current step.
66 67 |
# File 'lib/rex/ui/progress_tracker.rb', line 66 def step_status(msg = nil) end |