Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Spinner
- def initialize printer=nil
- @spinner = %w[| / - \\]
- @count = 0
- @printer ||= $stderr
- end
- def print
- @printer.print "\r"+@spinner[@count]
- @count += 1
- @count = 0 if @count > @spinner.size - 1
- end
- def self.print
- @spinner ||= new
- @spinner.print
- end
- end
- # 50.times{ Spinner.print; sleep 0.1 }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement