class Naginata::UI::Shell

Constants

LEVELS

Public Class Methods

new() click to toggle source
# File lib/naginata/ui/shell.rb, line 8
def initialize
  @shell = Thor::Base.shell.new
  @level = ENV['DEBUG'] ? "debug" : "info"
end

Public Instance Methods

debug(msg, newline = nil) click to toggle source
# File lib/naginata/ui/shell.rb, line 25
def debug(msg, newline = nil)
  tell_me(msg, nil, newline) if level("debug")
end
error(msg, newline = nil) click to toggle source
# File lib/naginata/ui/shell.rb, line 21
def error(msg, newline = nil)
  tell_me(msg, :red, newline) if level("error")
end
info(msg, newline = nil) click to toggle source
# File lib/naginata/ui/shell.rb, line 13
def info(msg, newline = nil)
  tell_me(msg, nil, newline) if level("info")
end
level(name = nil) click to toggle source
# File lib/naginata/ui/shell.rb, line 29
def level(name = nil)
  name ? LEVELS.index(name) <= LEVELS.index(@level) : @level
end
print_table(array, options = {}) click to toggle source
warn(msg, newline = nil) click to toggle source
# File lib/naginata/ui/shell.rb, line 17
def warn(msg, newline = nil)
  tell_me(msg, :yellow, newline) if level("warn")
end
yes?(msg) click to toggle source
# File lib/naginata/ui/shell.rb, line 33
def yes?(msg)
  @shell.yes?(msg)
end

Private Instance Methods

tell_me(msg, color = nil, newline = nil) click to toggle source
# File lib/naginata/ui/shell.rb, line 43
def tell_me(msg, color = nil, newline = nil)
  if newline.nil?
    @shell.say(msg, color)
  else
    @shell.say(msg, color, newline)
  end
end