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
# 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
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 (readonly)

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



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

def change_error()  end

#change_progressObject



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

def change_progress()  end

#change_textObject



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

def change_text()  end

#done_durObject



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

def done_dur() (Time.now-@start).seconds end

#done_relObject



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

def done_rel() 100.0*i/max end

#finishObject



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

def finish()  end

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



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

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

#total_durObject



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

def total_dur
  done_dur * max / i
end