Sha256: 5bdf2faff793f3690872a17dc98f60bee208bbac5f4ce74587330b3505729b92

Contents?: true

Size: 620 Bytes

Versions: 14

Compression:

Stored size: 620 Bytes

Contents

module CC
  module Analyzer
    module Formatters
      class Spinner
        def initialize(text)
          @spinner = TTY::Spinner.new(text)
        end

        def start
          @thread = Thread.new do
            loop do
              @spinning = true
              spinner.spin
              sleep 0.075
            end
          end
        end

        def stop(text = "Done!")
          if @spinning
            spinner.stop(text)
            print("\n")
            @thread.kill
          end
          @spinning = false
        end

        private

        attr_reader :spinner
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
codeclimate-0.0.21 lib/cc/analyzer/formatters/spinner.rb
codeclimate-0.0.18 lib/cc/analyzer/formatters/spinner.rb
codeclimate-0.0.17 lib/cc/analyzer/formatters/spinner.rb
codeclimate-0.0.16 lib/cc/analyzer/formatters/spinner.rb
codeclimate-0.0.15 lib/cc/analyzer/formatters/spinner.rb
codeclimate-0.0.14 lib/cc/analyzer/formatters/spinner.rb
codeclimate-0.0.13 lib/cc/analyzer/formatters/spinner.rb
codeclimate-0.0.11 lib/cc/analyzer/formatters/spinner.rb
codeclimate-0.0.10 lib/cc/analyzer/formatters/spinner.rb
codeclimate-0.0.9 lib/cc/analyzer/formatters/spinner.rb
codeclimate-0.0.7 lib/cc/analyzer/formatters/spinner.rb
codeclimate-0.0.6 lib/cc/analyzer/formatters/spinner.rb
codeclimate-0.0.5 lib/cc/analyzer/formatters/spinner.rb
codeclimate-0.0.1 lib/cc/analyzer/formatters/spinner.rb