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


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

#posObject

The current position in the progress.


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

def pos
  @pos
end

#startObject

The start of the progress.


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

def start
  @start
end

#stopObject

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