Sha256: b7b12795a6bf03201ac886b245e96443ec43577c6c4122abff80a7de2ccd7396
Contents?: true
Size: 900 Bytes
Versions: 2
Compression:
Stored size: 900 Bytes
Contents
# This code is free software; you can redistribute it and/or modify it under the # terms of the new BSD License. # # Copyright (c) 2009, Sebastian Staudt module Rubikon # A class for displaying and managing throbbers class Throbber < Thread SPINNER = '-\|/' # Creates and runs a Throbber that outputs to the given IO stream while the # given thread is alive # # # +ostream+:: The IO stream the throbber should be written to # +thread+:: The thread that should be watched def initialize(ostream, thread) proc = Proc.new do |ostream, thread| step = 0 ostream.putc 32 while thread.alive? ostream << "\b#{SPINNER[step].chr}" ostream.flush step = (step + 1) % 4 sleep 0.25 end ostream.putc 8 end super { proc.call(ostream, thread) } end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rubikon-0.2.1 | lib/rubikon/throbber.rb |
rubikon-0.2.0 | lib/rubikon/throbber.rb |