class Statistrano::Log::DefaultLogger::Formatter
Attributes
color[R]
msgs[R]
status[R]
width[R]
Public Class Methods
new(status, color, *msg)
click to toggle source
# File lib/statistrano/log/default_logger.rb, line 57 def initialize status, color, *msg @width = 14 @status = status.to_s @color = color @msgs = msg end
Public Instance Methods
output()
click to toggle source
# File lib/statistrano/log/default_logger.rb, line 64 def output Rainbow(anchor).bright + padding + Rainbow(status).public_send(color) + formatted_messages end
Private Instance Methods
anchor()
click to toggle source
# File lib/statistrano/log/default_logger.rb, line 70 def anchor "-> " end
formatted_messages()
click to toggle source
# File lib/statistrano/log/default_logger.rb, line 89 def formatted_messages messages = [] msgs.each_with_index do |msg, idx| if idx == 0 messages << " #{msg}" else messages << "#{spaces( anchor.length + width )} #{msg}" end end messages.join("\n") end
padding()
click to toggle source
# File lib/statistrano/log/default_logger.rb, line 74 def padding num = (width - status.length) if num < 0 @width = status.length + 1 return spaces(0) else return spaces num end end
spaces(num)
click to toggle source
# File lib/statistrano/log/default_logger.rb, line 85 def spaces num Array.new(num).join(" ") end