Sha256: f5c4d686dc4841d4a10512b1a826307ef150d143abbba5c4cd34081064624093

Contents?: true

Size: 427 Bytes

Versions: 19

Compression:

Stored size: 427 Bytes

Contents

require 'singleton'
require 'guignol'

module Guignol
  class TtySpinner
    include Singleton

    Chars = ['/','|','\\', '-']

    def initialize
      @state = 0
    end

    def spin!
      if $stderr.tty? && !Guignol.env.test?
        $stderr.write(Chars[@state % Chars.size] + "\r")
        $stderr.flush
        @state += 1
      end
      Thread.pass
    end

    def self.spin!
      instance.spin!
    end

  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
guignol-0.3.16 lib/guignol/tty_spinner.rb
guignol-0.3.15 lib/guignol/tty_spinner.rb
guignol-0.3.14 lib/guignol/tty_spinner.rb
guignol-0.3.13 lib/guignol/tty_spinner.rb
guignol-0.3.12 lib/guignol/tty_spinner.rb
guignol-0.3.10 lib/guignol/tty_spinner.rb
guignol-0.3.9 lib/guignol/tty_spinner.rb
guignol-0.3.8 lib/guignol/tty_spinner.rb
guignol-0.3.7 lib/guignol/tty_spinner.rb
guignol-0.3.6.2 lib/guignol/tty_spinner.rb
guignol-0.3.6.1 lib/guignol/tty_spinner.rb
guignol-0.3.6 lib/guignol/tty_spinner.rb
guignol-0.3.5.1 lib/guignol/tty_spinner.rb
guignol-0.3.5 lib/guignol/tty_spinner.rb
guignol-0.3.4 lib/guignol/tty_spinner.rb
guignol-0.3.3 lib/guignol/tty_spinner.rb
guignol-0.3.2 lib/guignol/tty_spinner.rb
guignol-0.3.1 lib/guignol/tty_spinner.rb
guignol-0.3.0 lib/guignol/tty_spinner.rb