Class: Eta::ProgressBar

Inherits:
Object
  • Object
show all
Defined in:
lib/eta.rb

Instance Method Summary collapse

Constructor Details

#initializeProgressBar

Returns a new instance of ProgressBar.



8
9
10
# File 'lib/eta.rb', line 8

def initialize
  @spinner = %w{/ - \\}.cycle
end

Instance Method Details

#draw(current, total) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'lib/eta.rb', line 18

def draw current, total
  print "\r"
  print "["
  progress = calculate_progress(current, total)
  not_progress = screen_width - progress - 2
  progress.times { print "#" }
  not_progress.times { print " " }
  print "]"
end

#draw_spinnerObject



12
13
14
15
16
# File 'lib/eta.rb', line 12

def draw_spinner
  print "\r"
  print @spinner.next
  print "\r"
end