Module: CollinsShell::PrinterUtil
- Included in:
- AssetPrinter, LogPrinter
- Defined in:
- lib/collins_shell/util/printer_util.rb
Instance Method Summary collapse
- #dynamic_terminal_width ⇒ Object
- #format_datetime(value) ⇒ Object
- #wrap_text(txt, col = 80) ⇒ Object
Instance Method Details
#dynamic_terminal_width ⇒ Object
20 21 22 23 24 |
# 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) ⇒ Object
7 8 9 10 11 12 13 14 |
# 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) ⇒ Object
16 17 18 |
# 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 |