Googleプログレスバー
http://googlejapan.blogspot.com/2007/07/20.html
何も考えずに作るとこんな感じ。
エスケープシーケンス使用。
def progress(str,per) pstr = "" p = (per*20) na = 0 na = p-6 if ( p >= 7 ) nd = 20-p pstr += "\x1b[34mT" if ( p >= 1 ) pstr += "\x1b[31ma" if ( p >= 2 ) pstr += "\x1b[33m"+"a"* na if ( na > 0 ) pstr += "\x1b[34mt" if ( p >= 3 ) pstr += "\x1b[32mt" if ( p >= 4 ) pstr += "\x1b[31my" if ( p >= 5 ) pstr += "\x1b[34mu" if ( p >= 6 ) pstr += "\x1b[30m"+"."* nd if ( nd > 0 ) print "#{str} \x1b[47m\x1b[30m|#{pstr}\x1b[30m|\x1b[37m\x1b[40m" end
ホントは出力時にカーソルも動かしてるんだけどまぁそれは自分でやってねみたいな。