Module: Spinner
- Defined in:
- lib/spinner.rb
Class Method Summary collapse
Class Method Details
.with_spinner(opts = {}) {|spin| ... } ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/spinner.rb', line 4 def with_spinner opts={}, &blk count = opts[:count] || nil = opts[:message] || "Working..." current = 0 shown = build_string , current, count printf shown spin = Proc.new do clear shown current += 1 shown = build_string , current, count printf shown end yield spin clear shown printf " " * shown.length clear shown end |