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.
15 16 17 18 19 |
# File 'lib/rex/ui/progress_tracker.rb', line 15 def initialize self.start = 0 self.stop = 0 self.pos = 0 end |
Instance Attribute Details
#pos ⇒ Object
The current position in the progress.
91 92 93 |
# File 'lib/rex/ui/progress_tracker.rb', line 91 def pos @pos end |
#start ⇒ Object
The start of the progress.
83 84 85 |
# File 'lib/rex/ui/progress_tracker.rb', line 83 def start @start end |
#stop ⇒ Object
The last position in the progress.
87 88 89 |
# File 'lib/rex/ui/progress_tracker.rb', line 87 def stop @stop end |
Instance Method Details
#abort(msg = nil) ⇒ Object
Progress has been aborted, the reason is supplied in msg.
77 78 |
# File 'lib/rex/ui/progress_tracker.rb', line 77 def abort(msg = nil) end |
#error(msg = nil) ⇒ Object
An error occurred that may result in aborting the progress.
71 72 |
# File 'lib/rex/ui/progress_tracker.rb', line 71 def error(msg = nil) end |
#range=(rng) ⇒ Object
Sets start and step using a range.
24 25 26 27 |
# File 'lib/rex/ui/progress_tracker.rb', line 24 def range=(rng) self.start = rng.begin self.stop = rng.end end |
#reset(n = self.start) ⇒ Object
Resets the current step location.
51 52 53 |
# File 'lib/rex/ui/progress_tracker.rb', line 51 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.
59 60 |
# File 'lib/rex/ui/progress_tracker.rb', line 59 def status(msg = nil) end |
#step(status = nil, n = 1) ⇒ Object
Steps with a given message and step size.
40 41 42 43 44 45 46 |
# File 'lib/rex/ui/progress_tracker.rb', line 40 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.
65 66 |
# File 'lib/rex/ui/progress_tracker.rb', line 65 def step_status(msg = nil) end |