Class: Gitrob::CLI::ProgressBar

Inherits:
Object
  • Object
show all
Defined in:
lib/gitrob/cli/progress_bar.rb

Instance Method Summary collapse

Constructor Details

#initialize(message, options = {}) ⇒ ProgressBar

Returns a new instance of ProgressBar.



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/gitrob/cli/progress_bar.rb', line 4

def initialize(message, options={})
  @options = {
    :format =>
      "#{'[*]'.light_blue} %t %c/%C %B %j% %e",
    :progress_mark => "|".light_blue,
    :remainder_mark => "|"
  }.merge(options)
  @mutex = Mutex.new
  Gitrob::CLI.info(message)
  @progress_bar = ::ProgressBar.create(@options)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/gitrob/cli/progress_bar.rb', line 32

def method_missing(method, *args, &block)
  if progress_bar.respond_to?(method)
    progress_bar.send(method, *args, &block)
  else
    super
  end
end

Instance Method Details

#error(message) ⇒ Object



24
25
26
# File 'lib/gitrob/cli/progress_bar.rb', line 24

def error(message)
  progress_bar.log("#{'[!]'.light_red} #{message}")
end

#finishObject



16
17
18
# File 'lib/gitrob/cli/progress_bar.rb', line 16

def finish
  progress_bar.finish
end

#info(message) ⇒ Object



20
21
22
# File 'lib/gitrob/cli/progress_bar.rb', line 20

def info(message)
  progress_bar.log("#{'[+]'.light_blue} #{message}")
end

#warn(message) ⇒ Object



28
29
30
# File 'lib/gitrob/cli/progress_bar.rb', line 28

def warn(message)
  progress_bar.log("#{'[!]'.light_yellow} #{message}")
end