Class: ProgressBar::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/progress-bar.rb

Direct Known Subclasses

Console, KDialog

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(max = nil, text = nil) ⇒ Base

Returns a new instance of Base.



18
19
20
21
# File 'lib/progress-bar.rb', line 18

def initialize max = nil, text = nil
	@start, @max, @i, @text, @error = Time.now, max || 100, 0, text || '', nil
	at_exit {finish}
end

Instance Attribute Details

#errorObject

Returns the value of attribute error.



16
17
18
# File 'lib/progress-bar.rb', line 16

def error
  @error
end

#iObject Also known as: to_i

Returns the value of attribute i.



16
17
18
# File 'lib/progress-bar.rb', line 16

def i
  @i
end

#maxObject

Returns the value of attribute max.



16
17
18
# File 'lib/progress-bar.rb', line 16

def max
  @max
end

#startObject

Returns the value of attribute start.



17
18
19
# File 'lib/progress-bar.rb', line 17

def start
  @start
end

#textObject

Returns the value of attribute text.



16
17
18
# File 'lib/progress-bar.rb', line 16

def text
  @text
end

Instance Method Details

#change_errorObject



55
# File 'lib/progress-bar.rb', line 55

def change_error()  end

#change_progressObject



53
# File 'lib/progress-bar.rb', line 53

def change_progress()  end

#change_textObject



54
# File 'lib/progress-bar.rb', line 54

def change_text()  end

#done_durObject



37
# File 'lib/progress-bar.rb', line 37

def done_dur() Time.now-@start end

#done_relObject



36
# File 'lib/progress-bar.rb', line 36

def done_rel() 100.0*i/max end

#finishObject



56
# File 'lib/progress-bar.rb', line 56

def finish()  end

#increment!(x = nil) ⇒ Object Also known as: inc!



33
# File 'lib/progress-bar.rb', line 33

def increment!( x = nil) self.i += (x || 1) end

#total_durObject



39
40
41
# File 'lib/progress-bar.rb', line 39

def total_dur
	done_dur * max / i
end