Class: Rex::Ui::ProgressTracker

Inherits:
Object
  • Object
show all
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

Text::ProgressTracker

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeProgressTracker

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

#posObject

The current position in the progress.



91
92
93
# File 'lib/rex/ui/progress_tracker.rb', line 91

def pos
  @pos
end

#startObject

The start of the progress.



83
84
85
# File 'lib/rex/ui/progress_tracker.rb', line 83

def start
  @start
end

#stopObject

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