Progress Bar on the Ruby

Member

makayla.beahan

by makayla.beahan , in category: Ruby , 24 days ago

Progress Bar on the Ruby 😝

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# progress bar

width = 60  # width of bar
com   = 540 # input data

pr = com * 0.01
i = 0
j = width

v = 1
puts
while pr <= com

  print "\r#{v}% [#{"|"*i}#{" "*j}]"

  pr += com * 0.01  

  i += width * 0.01
  j -= width * 0.01

  v += 1  
  
  sleep(0.01)
  
end
puts


Facebook Twitter LinkedIn Telegram Whatsapp Pocket

no answers