Class: Zubat::CLI::App::Progress

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/zubat/cli/app.rb

Instance Method Summary collapse

Constructor Details

#initialize(enum, silent:) ⇒ Progress

Returns a new instance of Progress.



60
61
62
63
# File 'lib/zubat/cli/app.rb', line 60

def initialize(enum, silent:)
  @enum = enum
  @silent = silent
end

Instance Method Details

#each(&block) ⇒ Object



65
66
67
68
69
70
71
72
73
74
75
# File 'lib/zubat/cli/app.rb', line 65

def each(&block)
  @enum.each_with_index do |elem, i|
    $stderr.print "\r#{%w[| / - \\][i % 4]} Analyzing... #{100 * i / @enum.size}%" unless @silent

    block.call(elem)
  end

  warn "\r✨ Analized                      \n\n" unless @silent

  @enum
end