Sha256: c10fff3de3d3df8a633e3978752b61f2214e52636984793cf3afb5f622e25aef
Contents?: true
Size: 645 Bytes
Versions: 2
Compression:
Stored size: 645 Bytes
Contents
class Progress def self.start(name, total = 100) @io ||= $stdout @io.sync = true @each = total / 1000 @count = 0 @current = 0 @total = total @name = name + ': %s' message highight('...') yield message percent @io.puts end def self.step @current += 1 if (@count += 1) >= @each message highight(percent) @count = 0 end end private def self.percent '%5.1f%%' % (@current * 100.0 / @total) end def self.message(s) @io.print "\r\e[0K#{@name % s}" end def self.highight(s) "\e[1m#{s}\e[0m" end end require 'enumerable' require 'integer'
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
toy-progress-0.0.1 | lib/progress.rb |
progress-0.0.1 | lib/progress.rb |