class Cl::Ui::Tty

Public Instance Methods

announce(msg, args = [], msgs = []) click to toggle source
# File lib/cl/ui.rb, line 94
def announce(msg, args = [], msgs = [])
  msg = format_msg(msg, args, msgs)
  puts colored(:green, with_spacing(msg, true))
end
cmd(msg) click to toggle source
# File lib/cl/ui.rb, line 124
def cmd(msg)
  notice("$ #{msg}")
end
error(msg, args = [], msgs = []) click to toggle source
# File lib/cl/ui.rb, line 114
def error(msg, args = [], msgs = [])
  msg = format_msg(msg, args, msgs)
  puts colored(:red, with_spacing(msg, true))
end
info(msg, args = [], msgs = []) click to toggle source
# File lib/cl/ui.rb, line 99
def info(msg, args = [], msgs = [])
  msg = format_msg(msg, args, msgs)
  puts colored(:blue, with_spacing(msg, true))
end
notice(msg, args = [], msgs = []) click to toggle source
# File lib/cl/ui.rb, line 104
def notice(msg, args = [], msgs = [])
  msg = format_msg(msg, args, msgs)
  puts colored(:gray, with_spacing(msg, false))
end
success(msg) click to toggle source
# File lib/cl/ui.rb, line 119
def success(msg)
  announce(msg)
  puts
end
warn(msg, args = [], msgs = []) click to toggle source
# File lib/cl/ui.rb, line 109
def warn(msg, args = [], msgs = [])
  msg = format_msg(msg, args, msgs)
  puts colored(:yellow, with_spacing(msg, false))
end

Private Instance Methods

colored(color, str) click to toggle source
Calls superclass method Cl::Ui::Colors#colored
# File lib/cl/ui.rb, line 130
def colored(color, str)
  opts[:color] ? super : str
end
format_msg(msg, args, msgs) click to toggle source
# File lib/cl/ui.rb, line 134
def format_msg(msg, args, msgs)
  msg = msgs[msg] % args if msg.is_a?(Symbol)
  msg.strip
end
with_spacing(str, space) click to toggle source
# File lib/cl/ui.rb, line 139
def with_spacing(str, space)
  str = "\n#{str}" if space && !@last
  @last = space
  str
end