السلام عليكم
عبارة عن شريط تقدم لكن لواجه سطر الأوامر
command-line interface
# A simple command-line interface progress bar
# Author: Abdelrahman ghanem <abom.jdev@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
class CLIProgressBar
def initialize(pchar="=")
@pchar=pchar
$stdout.sync=true #auto flush
end
def text=(ptext)
@text=ptext
end
def min=(pmin=0)
@min=pmin
end
def max=(pmax=100)
@max=pmax
end
def value=(pvalue)
#use \r [return] escape sequence
ratio=((pvalue.to_f/@max)*55).round
print "\r#{@text} #{ratio+45}% [#{@pchar*ratio}>#{"\s"*(55-ratio)}]"
print "\n" if pvalue==@max
end
end
طبعاً غير الرقم 55 براحتك
و لكن لا تنسى تغيير الرقم 45 ب:
100-55

test:
require 'cliprogress'
pb=CLIProgressBar.new
pb.text="Progress"
pb.max=100000
for i in 1..100000
pb.value=i
end
screenshot:

أى ملاحظات أو استفسار ؟

مرفق