class Starscope::Output

Constants

PBAR_FORMAT

Public Class Methods

new(level, out = STDOUT) click to toggle source
# File lib/starscope/output.rb, line 7
def initialize(level, out = STDOUT)
  @out = out
  @level = level
  @pbar = nil
end

Public Instance Methods

extra(msg) click to toggle source
# File lib/starscope/output.rb, line 29
def extra(msg)
  return unless @level == :verbose
  output(msg)
end
finish_pbar() click to toggle source
# File lib/starscope/output.rb, line 24
def finish_pbar
  @pbar.finish if @pbar
  @pbar = nil
end
inc_pbar() click to toggle source
# File lib/starscope/output.rb, line 20
def inc_pbar
  @pbar.increment if @pbar
end
new_pbar(title, num_items) click to toggle source
# File lib/starscope/output.rb, line 13
def new_pbar(title, num_items)
  return if @level == :quiet
  @pbar = ProgressBar.create(title: title, total: num_items,
                             format: PBAR_FORMAT, length: 80,
                             out: @out)
end
normal(msg) click to toggle source
# File lib/starscope/output.rb, line 34
def normal(msg)
  return if @level == :quiet
  output(msg)
end

Private Instance Methods

output(msg) click to toggle source
# File lib/starscope/output.rb, line 41
def output(msg)
  if @pbar
    @pbar.log(msg)
  else
    @out.puts msg
  end
end