module CollinsShell::PrinterUtil
Public Instance Methods
dynamic_terminal_width()
click to toggle source
# File lib/collins_shell/util/printer_util.rb, line 20 def dynamic_terminal_width highline_width = HighLine::SystemExtensions.terminal_size[1].to_i thor_width = Thor::Shell::Basic.new.terminal_width.to_i [highline_width,thor_width,80].max end
format_datetime(value)
click to toggle source
# File lib/collins_shell/util/printer_util.rb, line 7 def format_datetime value if !value.is_a?(DateTime) then val = DateTime.parse(value) else val = value end val.strftime('%Y-%m-%d %H:%M:%S') end
wrap_text(txt, col = 80)
click to toggle source
# File lib/collins_shell/util/printer_util.rb, line 16 def wrap_text(txt, col = 80) txt.gsub(/(.{1,#{col}})( +|$\n?)|(.{1,#{col}})/, "\\1\\3\n") end